Aug 9, 2022
0
Level 3
Allow actions according to a model attribute when selecting multiple items
I am new to Nova and am working on actions on a resource called Card_request.
When I select multiple models in the frontend, I want to filter available actions depending on an attribute of the Card_request model, say when $cardRequest->type === 5.
It works fine when the user clicks only one model in the frontend. However as soon as I select another line in the table, the following actions() method on my Nova Resource does not work:
public function actions(NovaRequest $request)
{
info($this->model()->type);
return [
(new Actions\ResendCard)->canSee(function () {
return $this->model()->type === 5;
})
->showInline(),
];
}
I got an empty log whenever I select multiple items in the table.
Is there a way to achieve this? If yes, I'd really be curious to know how, thank you!
Please or to participate in this conversation.