Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

fabiobettiol's avatar

Nova: Hide edit button on a Resource , but for some specific rows only

While in the Index view, I need to hide on certain records the edit button, instead on a per-resource basis. Is this possible? How?

Thanks in advance

0 likes
2 replies
LaryAI's avatar
Level 58

Certainly! In Laravel Nova, you can conditionally hide the edit button on a per-row basis by overriding the authorizedToUpdate method on the resource. This method determines if the edit button should be displayed for a given resource instance.

Here's how you can do it:

  1. Open the Nova resource file for the model you want to conditionally hide the edit button.
  2. Override the authorizedToUpdate method.
  3. Add your custom logic to determine when the edit button should be hidden.

Here's an example:

namespace App\Nova;

use Laravel\Nova\Http\Requests\NovaRequest;

class YourResource extends Resource
{
    // ...

    /**
     * Determine if the current user can update the given resource.
     *
     * @param  \Laravel\Nova\Http\Requests\NovaRequest  $request
     * @return bool
     */
    public function authorizedToUpdate(NovaRequest $request)
    {
        // Add your condition here. For example, if the resource has a 'status' field:
        if ($this->status == 'archived') {
            return false;
        }

        // Otherwise, use the default authorization logic
        return parent::authorizedToUpdate($request);
    }

    // ...
}

In the example above, the edit button will be hidden for rows where the status field is set to 'archived'. You can replace the condition with whatever logic applies to your specific use case.

Remember to import the NovaRequest at the top of your resource file if it's not already there.

This way, you can have fine-grained control over which records show the edit button in the index view of a Nova resource.

1 like
fabiobettiol's avatar

Thank you LaryAI... you are my man! ..... my bot, I mean. :)

Please or to participate in this conversation.