how to hide actions in lenses laravel-nova
actions are displayed in the table rows in all lenses pages how to hide them from lenses?
I already tried
public function actions(Request $request)
{
return [];
}
in the lense but it didn't work only when I remove the lens from original resource page it's hiding
Have you tried using a policy?
@briankidd
I tried this but it doesn't work either
->canSee(function () { return false;})
do you mean this or there is another way to do it?
with policy there is no way, from resourse model you can use canSee method on action with condition $request is not LensRequest::class.
define this in actions method of Resource class
$hideOnLens = function($request){
return !($request instanceof Laravel\Nova\Http\Requests\LensRequest);
};
return [
(new someAction)->canSee($hideOnLens),
];
Try below in resource to hide the view button from each row on lens.
public function authorizedToView(Request $request)
{
if ($request->lens && $request->lens == 'sales-report') {
return false;
}
return true;
}
Please or to participate in this conversation.