FilamentF
Filament8mo ago
10 replies
Glebka

How do I override getMaxContentWidth() globally?

Hi, I know about the ->maxContentWidth(MaxWidth::Full) method in an AdminPanelProvider, but it applies to every page. I need to apply it only to listRecords pages. Can I overwrite it for example in a AppServiceProvider?
Solution
I believe Filament uses xx.index for list pages. You could create a custom middleware and use something like this

public function handle(Request $request, Closure $next): Response
{
    $currentPanel = filament()->getCurrentPanel();

    if (str($request->route()->getAction('as'))->contains('index')) {
        $currentPanel->maxContentWidth(MaxWidth::Full);
    }

    return $next($request);
}


$panel
  ...
  ->middleware([
    ...
    CustomMiddleware::class
  ])
Was this page helpful?