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

avasa's avatar
Level 6

Laravel Nova Filter Viewable By Admins Only

Hi All,

I was wonder if there was a method to show certain Filters based on User roles?

Example, suppose I have a is_admin flag on my User table.

   Schema::create('users', function (Blueprint $table) {
        $table->bigIncrements('id');
        $table->string('name');
        $table->string('password');
        $table->boolean('is_admin')->default(0);
    });

    Schema::create('posts', function (Blueprint $table) {
        $table->bigIncrements('id');
        $table->string('name');
        $table->string('category');
    });

How do I have a Nova Filter for categories viewable for admins only?

Any help would be appreciated.

0 likes
1 reply
dipherent's avatar

if any one is passing by here wondering how to do this, here is how:

  if ($request->user()->isAdmin()) {
            return [
            
            
                new ByCompany,
                new DateFromFilter,
                new DateToFilter,
            ];
        }

        return [
              new ByCategory,
        ];

Please or to participate in this conversation.