Get corresponding model in laravel nova action fields function

19 views Asked by At

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 [
        //
    ];
}
1

There are 1 answers

0
heppi75 On

The only way I figured out was the solution to paste the model to the constructor of the action class:

public function actions(NovaRequest $request)
{
    return [
        (new Actions\MyAction($this))->onlyOnTableRow()
    ];
}

If this is really the best solution? Is there really no way to grab this from the NovaRequest?