Filament Multi-Panel Auth &amp; Table Query Tuning | Mohamed Said        [  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MH.png)   Mohamed Said Laravel Backend Engineer  ](https://www.msaied.com) [ Home ](https://www.msaied.com) [ Projects ](https://www.msaied.com/projects) [ Articles  ](https://www.msaied.com/articles) [ Certificates ](https://www.msaied.com/certificates) [ Contact ](https://www.msaied.com#contact-section) 

       [  ](https://github.com/EG-Mohamed)       

 [ Home ](https://www.msaied.com) [ Projects ](https://www.msaied.com/projects) [ Articles ](https://www.msaied.com/articles) [ Certificates ](https://www.msaied.com/certificates) [ Contact ](https://www.msaied.com#contact-section) 

  [ home ](https://www.msaied.com)    [ articles ](https://www.msaied.com/articles)    Filament at Scale: Multi-Panel Auth, Custom Panels, and Table Query Tuning        On this page       1. [  Why Multi-Panel Filament Gets Messy Fast ](#why-multi-panel-filament-gets-messy-fast)
2. [  1. Separate Auth Guards Per Panel ](#1-separate-auth-guards-per-panel)
3. [  2. Scoping Resources to the Authenticated Tenant ](#2-scoping-resources-to-the-authenticated-tenant)
4. [  3. Table Query Tuning: The Three Common Killers ](#3-table-query-tuning-the-three-common-killers)
5. [  3a. Eager-load relationships used in columns ](#3a-eager-load-relationships-used-in-columns)
6. [  3b. Defer expensive columns ](#3b-defer-expensive-columns)
7. [  3c. Paginate aggressively and add database indexes ](#3c-paginate-aggressively-and-add-database-indexes)
8. [  Takeaways ](#takeaways)

  ![Filament at Scale: Multi-Panel Auth, Custom Panels, and Table Query Tuning](https://cdn.msaied.com/183/62be0d95101cf6a9babfd701562186ed.png)

  #filament   #laravel   #multi-tenant   #performance  

 Filament at Scale: Multi-Panel Auth, Custom Panels, and Table Query Tuning 
============================================================================

     15 Jun 2026      3 min read    ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MJ.jpg)  Mohamed Said  

       Table of contents

1. [  01   Why Multi-Panel Filament Gets Messy Fast  ](#why-multi-panel-filament-gets-messy-fast)
2. [  02   1. Separate Auth Guards Per Panel  ](#1-separate-auth-guards-per-panel)
3. [  03   2. Scoping Resources to the Authenticated Tenant  ](#2-scoping-resources-to-the-authenticated-tenant)
4. [  04   3. Table Query Tuning: The Three Common Killers  ](#3-table-query-tuning-the-three-common-killers)
5. [  05   3a. Eager-load relationships used in columns  ](#3a-eager-load-relationships-used-in-columns)
6. [  06   3b. Defer expensive columns  ](#3b-defer-expensive-columns)
7. [  07   3c. Paginate aggressively and add database indexes  ](#3c-paginate-aggressively-and-add-database-indexes)
8. [  08   Takeaways  ](#takeaways)

 Why Multi-Panel Filament Gets Messy Fast
----------------------------------------

Filament's panel system is powerful, but teams often bolt on a second panel without thinking through auth isolation, query scope, or table performance. The result is shared session state, leaking queries, and N+1 problems hiding behind pretty UI. This article covers the three areas that matter most at scale.

---

1. Separate Auth Guards Per Panel
---------------------------------

Each panel should own its guard. Define them in `config/auth.php`:

```php
'guards' => [
    'admin' => [
        'driver'   => 'session',
        'provider' => 'admins',
    ],
    'tenant' => [
        'driver'   => 'session',
        'provider' => 'users',
    ],
],
'providers' => [
    'admins' => ['driver' => 'eloquent', 'model' => App\Models\Admin::class],
    'users'  => ['driver' => 'eloquent', 'model' => App\Models\User::class],
],

```

Then wire each panel to its guard inside the `PanelProvider`:

```php
// app/Providers/Filament/AdminPanelProvider.php
public function panel(Panel $panel): Panel
{
    return $panel
        ->id('admin')
        ->path('admin')
        ->authGuard('admin')
        ->login()
        ->middleware([
            EncryptCookies::class,
            StartSession::class,
            AuthenticateSession::class,
        ])
        ->authMiddleware([Authenticate::class]);
}

```

Critical: **do not share the default `web` middleware group** between panels unless you want session collisions. Each panel should declare its own middleware stack explicitly.

---

2. Scoping Resources to the Authenticated Tenant
------------------------------------------------

Global scopes are the cleanest way to ensure every Eloquent query inside a panel is automatically filtered. Register a scope in the panel's boot phase:

```php
// Inside TenantPanelProvider::panel()
->tenant(Team::class, ownershipRelationship: 'team')

```

For custom scoping beyond Filament's built-in tenancy, override `getEloquentQuery()` on the resource:

```php
public static function getEloquentQuery(): Builder
{
    return parent::getEloquentQuery()
        ->whereBelongsTo(filament()->getTenant());
}

```

Avoid putting this logic in a global Eloquent scope unless you also need it outside Filament — mixing panel concerns into your domain models is a maintenance trap.

---

3. Table Query Tuning: The Three Common Killers
-----------------------------------------------

### 3a. Eager-load relationships used in columns

```php
public static function table(Table $table): Table
{
    return $table
        ->query(
            Order::query()->with(['customer', 'items.product'])
        )
        ->columns([
            TextColumn::make('customer.name'),
            TextColumn::make('items_count')
                ->counts('items'),
        ]);
}

```

Filament's `->counts()` and `->exists()` column modifiers push aggregates into the base query rather than triggering per-row subqueries — use them instead of accessor methods.

### 3b. Defer expensive columns

For columns that require heavy joins or subqueries, mark them as toggleable and hidden by default:

```php
TextColumn::make('lifetime_value')
    ->toggleable(isToggledHiddenByDefault: true)
    ->getStateUsing(fn (Customer $r) => $r->orders()->sum('total')),

```

This keeps the default page load fast; power users can opt in.

### 3c. Paginate aggressively and add database indexes

Filament's default page size is 10, but teams often bump it to 50 or 100 without adding indexes on the sort column. Every `TextColumn::make('created_at')->sortable()` call becomes an `ORDER BY created_at` — ensure that column is indexed:

```php
$table->index(['team_id', 'created_at']);

```

A composite index on `(team_id, created_at)` satisfies both the tenant scope `WHERE` and the `ORDER BY` in a single index scan.

---

Takeaways
---------

- Assign a dedicated auth guard to every panel and declare middleware stacks explicitly to prevent session bleed.
- Scope resource queries at the resource level, not in global Eloquent scopes, to keep domain models clean.
- Use Filament's built-in `->counts()` and `->exists()` modifiers to push aggregates into SQL rather than PHP.
- Hide expensive columns behind `toggleable(isToggledHiddenByDefault: true)` to protect default page load times.
- Add composite indexes that match your tenant scope column plus the default sort column.

 Found this useful?

          [  ](https://twitter.com/intent/tweet?url=https%3A%2F%2Fwww.msaied.com%2Farticles%2Ffilament-at-scale-multi-panel-auth-custom-panels-and-table-query-tuning&text=Filament+at+Scale%3A+Multi-Panel+Auth%2C+Custom+Panels%2C+and+Table+Query+Tuning) [  ](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fwww.msaied.com%2Farticles%2Ffilament-at-scale-multi-panel-auth-custom-panels-and-table-query-tuning) 

 Frequently Asked Questions 
----------------------------

  3 questions  

     Q01  Can two Filament panels share the same Eloquent model for authentication?        Yes, but they should still use separate guards pointing to the same provider. This keeps session cookies and remember tokens isolated between panels, preventing one panel's logout from affecting the other. 

      Q02  Does Filament's built-in tenancy handle multi-panel setups automatically?        Filament's tenant() helper scopes one panel to a tenant model, but it does not coordinate across multiple panels. You need to configure tenancy independently on each PanelProvider and ensure middleware stacks do not overlap. 

      Q03  When should I override getEloquentQuery() versus using a global Eloquent scope?        Override getEloquentQuery() when the scope is specific to the Filament panel context. Reserve global Eloquent scopes for rules that must apply everywhere — API, CLI, and UI alike — to avoid unintended filtering outside the panel. 

  Continue reading

 More Articles 
---------------

 [ View all    ](https://www.msaied.com/articles) 

 [ ![Laravel Telescope Alternatives: Building a Lightweight Request Inspector with Middleware](https://cdn.msaied.com/216/9b6d240010b80483f072902dafcd216c.png) laravel middleware debugging 

### Laravel Telescope Alternatives: Building a Lightweight Request Inspector with Middleware

Telescope is powerful but heavy for production. Learn how to build a focused, low-overhead request inspector u...

  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MJ.jpg)  Mohamed Said 

 16 Jun 2026     1 min read  

  Read    

 ](https://www.msaied.com/articles/laravel-telescope-alternatives-building-a-lightweight-request-inspector-with-middleware) [ ![RAG Pipelines in Laravel: Chunking, Embedding, and Retrieval with pgvector](https://cdn.msaied.com/215/e037e13535aa77822f879ee829ec3f68.png) laravel ai pgvector 

### RAG Pipelines in Laravel: Chunking, Embedding, and Retrieval with pgvector

Build a production-ready Retrieval-Augmented Generation pipeline in Laravel using pgvector, OpenAI embeddings,...

  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MJ.jpg)  Mohamed Said 

 16 Jun 2026     3 min read  

  Read    

 ](https://www.msaied.com/articles/rag-pipelines-in-laravel-chunking-embedding-and-retrieval-with-pgvector) [ ![Laravel Pest: Architecture Tests, Mutation Testing, and Type Coverage in CI](https://cdn.msaied.com/214/0d4822fa8ee1765d0689e387dd849d92.png) laravel pest testing 

### Laravel Pest: Architecture Tests, Mutation Testing, and Type Coverage in CI

Go beyond feature tests. Learn how to enforce architectural rules, catch logic gaps with mutation testing, and...

  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MJ.jpg)  Mohamed Said 

 16 Jun 2026     4 min read  

  Read    

 ](https://www.msaied.com/articles/laravel-pest-architecture-tests-mutation-testing-and-type-coverage-in-ci) 

   [  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MH.png)   Mohamed Said Laravel Backend Engineer  ](https://www.msaied.com)Senior Backend Engineer specializing in Laravel, scalable SaaS platforms, APIs, and cloud infrastructure. I build secure, high-performance web applications that help businesses grow.

Explore

- [Home](https://www.msaied.com)
- [Projects](https://www.msaied.com/projects)
- [Articles](https://www.msaied.com/articles)
- [Certificates](https://www.msaied.com/certificates)
- [Contact](https://www.msaied.com#contact-section)

Connect

- [   hello@msaied.com ](mailto:hello@msaied.com)
- [   +20 109 461 9204 ](tel:+201094619204)

© 2026 Mohamed Said. All rights reserved.

 [  ](https://github.com/EG-Mohamed) [  ](https://www.linkedin.com/in/msaiedm/) [  ](https://wa.me/201094619204) [  ](mailto:hello@msaied.com) [  ](https://drive.google.com/file/u/0/d/1MF20IPRJyzfy32mhEutjL5EpSls0w2Q8/view)
