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

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

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

  [ home ](https://msaied.com)    [ articles ](https://msaied.com/articles)    Filament at Scale: Multi-Panel Auth, Custom Panels, and Table Query Tuning        On this page       1. [  Filament at Scale: Multi-Panel Auth, Custom Panels, and Table Query Tuning ](#filament-at-scale-multi-panel-auth-custom-panels-and-table-query-tuning)
2. [  Registering Multiple Panels ](#registering-multiple-panels)
3. [  Per-Panel Middleware Stacks ](#per-panel-middleware-stacks)
4. [  Scoping Table Queries Without Global Scopes ](#scoping-table-queries-without-global-scopes)
5. [  Table Query Tuning: The Real Bottlenecks ](#table-query-tuning-the-real-bottlenecks)
6. [  Eager Loading in Table Columns ](#eager-loading-in-table-columns)
7. [  Covering Indexes for Filter Columns ](#covering-indexes-for-filter-columns)
8. [  Key Takeaways ](#key-takeaways)

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

  #filament   #laravel   #multi-panel   #performance  

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

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

       Table of contents

1. [  01   Filament at Scale: Multi-Panel Auth, Custom Panels, and Table Query Tuning  ](#filament-at-scale-multi-panel-auth-custom-panels-and-table-query-tuning)
2. [  02   Registering Multiple Panels  ](#registering-multiple-panels)
3. [  03   Per-Panel Middleware Stacks  ](#per-panel-middleware-stacks)
4. [  04   Scoping Table Queries Without Global Scopes  ](#scoping-table-queries-without-global-scopes)
5. [  05   Table Query Tuning: The Real Bottlenecks  ](#table-query-tuning-the-real-bottlenecks)
6. [  06   Eager Loading in Table Columns  ](#eager-loading-in-table-columns)
7. [  07   Covering Indexes for Filter Columns  ](#covering-indexes-for-filter-columns)
8. [  08   Key Takeaways  ](#key-takeaways)

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

Most Filament tutorials assume a single admin panel with a single `users` table. Production SaaS apps rarely look like that. You might have a customer-facing portal, an internal ops panel, and a super-admin panel — each with its own guard, middleware, and data scope. Getting that wrong means auth bleed, slow tables, and unmaintainable panel code.

### Registering Multiple Panels

Each panel lives in its own `PanelProvider`. Register them all in `bootstrap/providers.php`:

```php
// app/Providers/Filament/CustomerPanelProvider.php
class CustomerPanelProvider extends PanelProvider
{
    public function panel(Panel $panel): Panel
    {
        return $panel
            ->id('customer')
            ->path('portal')
            ->authGuard('customer')
            ->login(CustomerLogin::class)
            ->middleware([
                EncryptCookies::class,
                StartSession::class,
                EnsureEmailIsVerified::class,
            ])
            ->authMiddleware([Authenticate::class])
            ->discoverResources(
                in: app_path('Filament/Customer/Resources'),
                for: 'App\\Filament\\Customer\\Resources'
            );
    }
}

```

The `->authGuard('customer')` call is the critical line. Filament will use that guard for all authentication checks within this panel, completely isolated from your `admin` guard.

### Per-Panel Middleware Stacks

Don't share middleware stacks between panels unless you have a deliberate reason. The `->middleware()` call sets the web-layer stack; `->authMiddleware()` runs after authentication resolves. A common pattern is adding a tenant-scoping middleware only to the customer panel:

```php
->authMiddleware([
    Authenticate::class,
    ApplyTenantScope::class, // sets app()->instance('current_tenant', ...)
])

```

This keeps the ops panel free of tenant logic entirely.

### Scoping Table Queries Without Global Scopes

Global Eloquent scopes are tempting but dangerous across panels — they apply everywhere, including jobs and CLI commands. Instead, scope at the resource level:

```php
// app/Filament/Customer/Resources/OrderResource.php
public static function getEloquentQuery(): Builder
{
    return parent::getEloquentQuery()
        ->whereBelongsTo(app('current_tenant'), 'tenant')
        ->with(['items', 'status']);
}

```

This query runs only when the Filament table renders. No leakage.

### Table Query Tuning: The Real Bottlenecks

Filament tables generate a `COUNT(*)` query for pagination alongside the data query. On large tables this is expensive. Use `->paginationPageOptions([25, 50])` and consider disabling the count entirely for very large datasets:

```php
public static function table(Table $table): Table
{
    return $table
        ->query(fn () => static::getEloquentQuery())
        ->paginationPageOptions([25, 50])
        ->defaultPaginationPageOption(25)
        ->extremePaginationLinks(false)
        ->columns([...]);
}

```

For tables exceeding 500k rows, switch to simple pagination to drop the `COUNT`:

```php
->paginated([25, 50])
->paginateUsing(fn (Builder $query, int $page, int $perPage) =>
    $query->simplePaginate($perPage, page: $page)
)

```

### Eager Loading in Table Columns

Filament does not automatically eager-load relationships referenced in columns. Declare them explicitly:

```php
TextColumn::make('customer.name')
    ->label('Customer')
    ->searchable(query: fn (Builder $q, string $s) =>
        $q->whereHas('customer', fn ($q) => $q->where('name', 'like', "%{$s}%"))
    ),

```

And in `getEloquentQuery()`:

```php
return parent::getEloquentQuery()->with(['customer', 'items.product']);

```

Missing this on a 10k-row table produces thousands of queries per page load.

### Covering Indexes for Filter Columns

Filament filter dropdowns translate to `WHERE` clauses. If your `orders` table is filtered by `status` and sorted by `created_at`, add a composite index:

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

```

The column order matters: equality columns first, range/sort columns last.

### Key Takeaways

- Register each panel in its own `PanelProvider` with a dedicated `authGuard`.
- Scope table queries in `getEloquentQuery()`, not via global Eloquent scopes.
- Disable `COUNT(*)` pagination on very large tables using `simplePaginate`.
- Declare eager loads explicitly — Filament will not infer them from column definitions.
- Add composite indexes that match your filter + sort column order.

 Found this useful?

          [  ](https://twitter.com/intent/tweet?url=https%3A%2F%2Fmsaied.com%2Farticles%2Ffilament-at-scale-multi-panel-auth-custom-panels-and-table-query-tuning-2&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%2Fmsaied.com%2Farticles%2Ffilament-at-scale-multi-panel-auth-custom-panels-and-table-query-tuning-2) 

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

  3 questions  

     Q01  Can two Filament panels share the same Eloquent models but use different guards?        Yes. Guards control authentication, not model access. Both panels can query the same models; the difference is which user table and token driver authenticates the request. Scope queries per-panel inside `getEloquentQuery()` rather than relying on the guard to restrict data. 

      Q02  How do I prevent a Filament resource registered in one panel from appearing in another?        Use `-&gt;discoverResources(in: ..., for: ...)` with panel-specific namespaces, or register resources explicitly with `-&gt;resources([...])`. Resources are scoped to the panel they are registered in and will not bleed across panels. 

      Q03  Does switching to simplePaginate break Filament's built-in pagination UI?        Simple pagination removes the total-count-based page links, so users see only previous/next controls. Filament renders this correctly when you return a `Paginator` instance from `paginateUsing`. It is a deliberate UX trade-off worth making on very large datasets. 

  Continue reading

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

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

 [ ![Domain-Driven Design in Laravel: Value Objects, DTOs, and Actions Without Bloat](https://cdn.msaied.com/377/b5c2aef77aed51ee8694f377085af424.png) laravel ddd architecture 

### Domain-Driven Design in Laravel: Value Objects, DTOs, and Actions Without Bloat

Learn how to model domain concepts with value objects, DTOs, and single-action classes in Laravel — keeping yo...

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

 6 Jul 2026     4 min read  

  Read    

 ](https://msaied.com/articles/domain-driven-design-in-laravel-value-objects-dtos-and-actions-without-bloat) [ ![What's Missing from Your PHP Development Environment: Meet DDLess](https://cdn.msaied.com/379/baa8990d4c7b46d18498d69d68f9b6d2.png) DDLess PHP Debugging Laravel Tools 

### What's Missing from Your PHP Development Environment: Meet DDLess

DDLess is a PHP development workbench that brings step debugging, an in-breakpoint playground, and an interact...

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

 6 Jul 2026     3 min read  

  Read    

 ](https://msaied.com/articles/whats-missing-from-your-php-development-environment-meet-ddless) [ ![CQRS in Laravel Without a Framework: Commands, Handlers, and Query Objects](https://cdn.msaied.com/376/bec9da4b7a7ddeee26dac3df6f5d6c44.png) laravel cqrs architecture 

### CQRS in Laravel Without a Framework: Commands, Handlers, and Query Objects

Skip the heavy CQRS libraries. Learn how to implement commands, command handlers, and query objects in plain L...

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

 6 Jul 2026     3 min read  

  Read    

 ](https://msaied.com/articles/cqrs-in-laravel-without-a-framework-commands-handlers-and-query-objects) 

   [  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MH.png)   Mohamed Said Laravel Backend Engineer  ](https://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://msaied.com)
- [Projects](https://msaied.com/projects)
- [Articles](https://msaied.com/articles)
- [Certificates](https://msaied.com/certificates)
- [Contact](https://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)
