I've always used approach where I decide within the action if that resource/model should be affected by the action.
Jun 20, 2020
4
Level 7
Condional Nova Actions
Hello,
I have some actions on table row, but I need to display actions in condition.
I tried to use canSee()
(new SetThingInProgress())
->showOnTableRow()
->canSee(function ($req) {
return $this->resource->status == Thing::PENDING;
}),
Well, $this->resource it returns only the Model like just an instance, so $this->resource->status it obviously returns NULL. so canSee() is not working for me.
If I want to access to the property resource I have to use canRun()
which accepts two params (NovaRequest, Model)
(new SetThingInProgress())
->showOnTableRow()
->canRun(function ($req, Thing $thing) {
return $thing->status == Thing::PENDING;
}),
But that will help just users to run this action in condition.
Any suggestion please, maybe I missed something in the doc.
Please or to participate in this conversation.