First hour of a new Filament project

Published on Jul 20, 2024

So you've just read through First hour of a new Laravel project, and you have decided to install Filament as an admin panel. Here are the steps I would take to configure a new Filament admin panel.

Unsaved changes alerts

When you have resources with long forms, it can be very painful to lose filled in data after accidentally closing a tab. After enabling this setting, Filament will ask the user for confirmation when they close a form that has changes.

// AppPanelProvider.php
 
public function panel(Panel $panel): Panel
{
return $panel
...
->unsavedChangesAlerts(); 
}
)

Allow password resets

By default, you can't reset your own password in a Filament admin panel. To give your users some autonomy, you can enable this feature.

// AppPanelProvider.php
 
public function panel(Panel $panel): Panel
{
return $panel
...
->passwordReset(); 
}
)

Enabling profile

In a similar vein, you can enable the user profile, so users can change their own email and password.

// AppPanelProvider.php
 
public function panel(Panel $panel): Panel
{
return $panel
...
->profile(); 
}
)

Top navigation

When you're starting out on a new project, you probably won't have that many menu items yet. You may want to enable top navigation to reclaim some horizontal space.

// AppPanelProvider.php
 
public function panel(Panel $panel): Panel
{
return $panel
...
->topNavigation(); 
}
)

Notifications

Most admin panels will send some form of notifications to their admins. By default, Filament will use Livewire's polling feature to check for new notifications. If you need real-time notifications, check out the docs to set up a websocket.

// AppPanelProvider.php
 
public function panel(Panel $panel): Panel
{
return $panel
...
->databaseNotifications() 
->databaseNotificationsPolling('30s'); 
}
)

Pagination

At some point, you probably will have a lot of rows in a Filament table, and at some point someone will attempt to show all records and they will complain that it won't work. With the option to show 100 records, I personally don't feel the need to show all and that's why I like to disable that option in all my tables:

use Filament\Tables\Table;
 
// You can place this in any service provider
public function boot()
{
Table::configureUsing(fn (Table $table) => $table->paginationPageOptions([10, 25, 50, 100])); 
}

If there's a Resource you'd like to override this for, you can use the ->paginated() method on the $table:

use Filament\Tables\Table;
 
public function table(Table $table): Table
{
return $table
->paginated([10, 25, 50, 100, 'all']); 
}

Well, this probably took you less than an hour to configure. Good luck with your new Filament admin panel!

Do you have feedback or comments? Let me know on Twitter!