Filament v3: The Ultimate Guide to Building Admin Panels in Laravel

Introduction

Filament v3 is a powerful, feature-rich admin panel and form builder for Laravel. It provides an elegant and highly customizable interface for managing application data while simplifying the development process. Whether you’re working on a SaaS platform, an eCommerce store, or an internal dashboard, Filament v3 is an excellent choice for building complex applications with minimal effort.

In this blog, we’ll explore the key features of Filament v3, its improvements over previous versions, and how you can leverage it in your Laravel projects.


Why Choose Filament v3?

Filament has been a game-changer for Laravel developers, offering an easy-to-use yet powerful framework for admin panels. Here’s why Filament v3 stands out:

  • Enhanced UI/UX: A refined and modern UI built with Tailwind CSS.
  • Multi-Panel Support: Easily create multiple admin panels for different user roles.
  • Livewire 3 Support: Offers seamless integration with Livewire 3, enhancing interactivity.
  • Faster Performance: Optimized database queries and component rendering.
  • Advanced Role & Permission Management: Works well with Spatie’s Role-Permission package.
  • Customization Flexibility: Extend Filament components and create reusable widgets.
  • Dark Mode: Built-in support for dark mode for a better user experience.

Getting Started with Filament v3

1. Installing Filament v3 in Laravel 11

To install Filament in a Laravel project, run:

composer require filament/filament

Once installed, publish the configuration file using:

php artisan vendor:publish --tag=filament-config

2. Creating an Admin Panel

Filament allows you to create an admin panel effortlessly. Generate a new panel using:

php artisan make:filament-panel admin

This command creates an admin panel with authentication and basic navigation setup.


Defining Resources in Filament v3

Filament’s core revolves around Resources, which manage CRUD operations for models. You can generate a resource using:

php artisan make:filament-resource Product

This will create a ProductResource.php file inside app/Filament/Resources/. Here, you can define fields, filters, actions, and relationships.

Example: Adding Fields to a Resource

use Filament\Resources\Form;
use Filament\Resources\Table;

class ProductResource extends Resource
{
    protected static ?string $model = Product::class;

    public static function form(Form $form): Form
    {
        return $form
            ->schema([
                TextInput::make('name')->required(),
                TextInput::make('price')->numeric()->required(),
            ]);
    }

    public static function table(Table $table): Table
    {
        return $table
            ->columns([
                TextColumn::make('name')->sortable(),
                TextColumn::make('price')->sortable(),
            ]);
    }
}

Multi-Panel Support in Filament v3

Filament v3 introduces multi-panel support, allowing you to create different dashboards for different user roles.

To create a new panel:

php artisan make:filament-panel guest

You can now register resources selectively for each panel inside PanelProvider.php.


Role & Permission Management

For role-based access control, install Spatie’s package:

composer require spatie/laravel-permission

Assign roles in Filament resources:

public static function canViewAny(): bool
{
    return auth()->user()->hasRole('admin');
}

Customizing Filament

Adding Custom Widgets

Filament allows you to add dashboard widgets to display statistics or custom information:

php artisan make:filament-widget SalesOverview

This generates a widget file where you can define the UI components.

Extending Filament Pages

If you need a custom page, use:

php artisan make:filament-page Reports

Customize the page layout by modifying Reports.php.


Conclusion

Filament v3 is an excellent choice for developers looking to build robust admin panels with Laravel. With its seamless integration with Livewire, Tailwind CSS, and multi-panel support, it simplifies complex tasks and improves the development workflow. Whether you’re managing users, handling product inventories, or visualizing data, Filament provides an intuitive and developer-friendly solution.

If you haven’t tried Filament yet, now is the time to explore its capabilities and enhance your Laravel applications.


 

🚀 Start using Filament v3 today and build powerful admin panels effortlessly!

Leave a Reply

Your email address will not be published. Required fields are marked *