Laravel, Laravel Filament

How to Create a Publicly Accessible Panel in Laravel Filament 3

In Laravel Filament 3 you can create a publicly accessible panel by removing all of the authentication elements from the panel. If you create a fresh panel, you would need to remove the elements below:

class PublicPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel
->id('public')
->path('public')
->colors([
'primary' => Color::<em>Amber</em>,
])
->discoverResources(in: app_path('Filament/Public/Resources'), for: 'App\\Filament\\Public\\Resources')
->discoverPages(in: app_path('Filament/Public/Pages'), for: 'App\\Filament\\Public\\Pages')
->pages([
Pages\Dashboard::class,
])
->discoverWidgets(in: app_path('Filament/Public/Widgets'), for: 'App\\Filament\\Public\\Widgets')
->widgets([
- Widgets\AccountWidget::class,
Widgets\FilamentInfoWidget::class,
])
->middleware([
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
StartSession::class,
AuthenticateSession::class,
ShareErrorsFromSession::class,
VerifyCsrfToken::class,
SubstituteBindings::class,
DisableBladeIconComponents::class,
DispatchServingFilamentEvent::class,
])
- ->authMiddleware([
- Authenticate::class,
- ]);
}
}

After you make these changes, then you should be able to access the panel without logging in. Please note that you will not be able to use the auth()->user() in this panel because there is no auth user.

While public panels are accessible without authentication, it's essential to ensure sensitive data or functionalities are not exposed unintentionally. Review your panel's resources to make sure no data is exposed accidentally.

Syntax highlighting by Torchlight.

Remote World

Ready to take the next step?

Give me a email!

chester@remoteworld.dev