tunezilla / nova-dynamic-action-fields

Dynamic Action Fields for Laravel Nova
https://packagist.org/packages/tunezilla/dynamic-action-fields
MIT License
18 stars 6 forks source link

Nova 4 #3

Open danielschweiger opened 2 years ago

danielschweiger commented 2 years ago

Will this work with Nova 4?

tunezilla commented 2 years ago

We're not sure at the moment and we haven't upgraded / bought a license for Nova 4 ourselves yet.

I think the most likely parts to break would be the ones that assume Nova internals like:

Naoray commented 1 year ago

In case anyone else is wondering on how to use dynamic actions in Nova v4:

You don’t need any third party package, it can be done out of the box:

In nova v4 actions can be one of the following types:

Normal actions If your action fits into the normal use case, you just have to return an empty array when no resources are included in the request (no clue why this is requested on an initial load from nova)

public function fields(NovaRequest $request): array
{
    if (!$posts = $request->selectedResources()) {
        return [];
    }

    // return the fields
}

Sole actions Sole actions are even simpler, since nova is only doing a request when one resource gets selected, you can use the findModel() method on the NovaRequest to get your model

public function fields(NovaRequest $request): array
{
    // query your specific models
    $posts = $request->findModel();

    // return the fields
}

EDIT: It looked like it works the way I described above only when not using the ->showInline() method. Hence, this package might still be able to add some value