skip to Main Content

I am currently working on a Laravel project using filamentPHP. However I cannot find a way to delete the create functionality for a specific resource.
Considering there is a resource named Customer, in the view page, I would like to remove the new customer button located at the top of the list. Is there any way to do that?

3

Answers


  1. Chosen as BEST ANSWER

    A Laravel specific solution is to create a new policy, and override the create() function to return false, like the following:

    public function create()
    {
       return false;
    }
    

    Note: Do not forget to assign the required model to this new policy in /Providers/AuthServiceProvider.php.


  2. You can remove it by override canCreate() and return it as false.

    class Customer
    {
       public static $resource = CustomerResource::class;
    
       protected function canCreate(): bool
       {
          return false;
       }
    }
    
    Login or Signup to reply.
  3. I’m using filament v2.16.66 with Laravel 9.19.

    What works for me in order to remove create button in certain lists, is adding the following function in eg: AppFilamentResourcesCustomerResource

        public static function canCreate(): bool
       {
          return false;
       }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search