How can I get the current model in the laravel nova actions field function? Can’t find it out …
public function fields(NovaRequest $request)
{
Log::info($request->model());
return [
//
];
}
How can I get the current model in the laravel nova actions field function? Can’t find it out …
public function fields(NovaRequest $request)
{
Log::info($request->model());
return [
//
];
}
2
Answers
The only way I figured out was the solution to paste the model to the constructor of the action class:
If this is really the best solution? Is there really no way to grab this from the NovaRequest?
Yes, there is a way to access the resources from the NovaRequest.
I don’t believe this is officially documented by Laravel Nova, but here are the two implementations for Index and Detail views.