Search code examples
laravellaravel-nova

hide actions in lense laravel nova


how to hide actions in the lense page I have following actions in my resource

    public function actions(Request $request)
{
    return [
        (new AddNewURL)
            ->canSee(function () use ($request) { return $request->user()->hasPermission('updatedOrders-create');})
            ->canRun(function () use ($request) { return $request->user()->hasPermission('updatedOrders-create');})
            ->withoutConfirmation(),
        (new EditNewURL)
            ->canSee(function () use ($request) { return $request->user()->hasPermission('updatedOrders-update-all');})
            ->canRun(function () use ($request) { return $request->user()->hasPermission('updatedOrders-update-all');})
            ->withoutConfirmation(),
        (new PrintBillings)
            ->withoutConfirmation()
            ->canSee(function () use ($request) { return $request->user()->hasPermission('orders-actions-print');})
            ->canRun(function () use ($request) { return $request->user()->hasPermission('orders-actions-print');}),
        (new DownloadExcel)
            ->onlyOnIndex()
            ->withoutConfirmation(),
    ];
}

I want to hide them in the lense page I already tried

public function actions(Request $request)
{
    return [];
}

in the lense class but didn't work, also I removed the actions method completely yet it doesn't work. also, I tried ->canSee(function () { return false;}) yet it doesn't work !!!!


Solution

  • the actions that are shown in the table rows can not be overridden, but the actions that are shown in the index top right corner can be overridden by overriding action method on the lense.

    public function actions(Request $request)
    {
        return [];
    }
    

    in this case, all actions that are shown in index will be gone