@knubbe Thanks for hint.
In nova resources, action method, if you define a action class and use it onlyOnTableRow will only works on resource List view(aka Index). if you want same action on Detail view(aka read view) then you don't need to use onlyOnTableRow. but real problem is that in nova route nova-api/{resource}/actions?resourceId={number} it is not loading resource at all may be kind a bug in Nova!
As solution,
in Resource file : app/Nova/{your-resource}.php
public function actions(Request $request)
{
return [
new BookEventAction,
(new AddAnonymousUserAction($this->model()))->showOnTableRow() // here $this->model() returns resource model.
];
}
in Action file : app/Nova/Actions/{your-action}.php
class AddAnonymousUser extends Action
{
...
public $model;
function __construct($model = null)
{
$this->model = $model;
if(!is_null($resourceId = request('resourceId'))){
$this->model = Event::find($resourceId); //Event is my Resource class, you can make this one dynamic too. nova/route/api.php get Actions route. ;)
}
}
...
public function fields()
{
return [
Select::make('Customer')
->options(\App\Models\Customer::all()->pluck('company', 'id'))
->searchable(),
->withMeta(['value' => optional($this->model)->customer_id],
];
}
}
PS : snippit will give you idea about how nova route works. DON'T COPY+PASTE, my resource/action class is not same as yours.