Filament has indeed grown into a more comprehensive admin panel ecosystem for Laravel. The mention of "Multi-tenancy built for SaaS" likely refers to the fact that Filament can be used to build multi-tenant applications, which are essential for SaaS (Software as a Service) platforms.
Multi-tenancy is an architecture where a single instance of the software runs on a server, serving multiple tenants (clients or customers). Each tenant's data is isolated and remains invisible to other tenants. This is a common requirement for SaaS applications, where you might have different companies or users with their own separate data.
While Filament provides a solid foundation for building admin panels and includes a variety of tools and components to speed up development, it does not include a full SaaS suite out of the box. For features like subscription billing, you would still need to integrate with a service like Laravel Spark or implement your own solution using Laravel Cashier.
Here's a basic outline of how you might set up a SaaS application using Filament:
-
Set up a multi-tenant architecture: You can use packages like
spatie/laravel-multitenancyto handle the multi-tenancy aspect of your application. This will allow you to manage multiple tenants with separate databases or prefixed tables within a single database. -
Install Filament: Follow the installation instructions on the Filament documentation to get the admin panel up and running.
-
Customize Filament for your needs: Create custom resources, forms, and tables to manage the data for your application.
-
Integrate subscription management: Use Laravel Cashier or Spark to handle subscription billing. You'll need to set up plans, handle subscription logic, and integrate with a payment gateway like Stripe or Paddle.
-
Secure your application: Ensure that users can only access their own data by scoping queries to the current tenant and implementing proper authentication and authorization.
Here's a very simplified example of how you might define a Filament resource in a multi-tenant SaaS application:
use Filament\Resources\Form;
use Filament\Resources\Table;
use Filament\Resources\Resource;
use App\Models\TenantSpecificModel;
class TenantSpecificResource extends Resource
{
public static function form(Form $form)
{
return $form
->schema([
// Define your form fields here
]);
}
public static function table(Table $table)
{
return $table
->columns([
// Define your table columns here
])
->filters([
// Define your table filters here
]);
}
public static function getModel()
{
return TenantSpecificModel::class;
}
public static function getQuery()
{
// Scope the query to the current tenant
return parent::getQuery()->where('tenant_id', auth()->user()->tenant_id);
}
}
In this example, TenantSpecificModel would be a model that is scoped to the current tenant, ensuring that users only see their own data.
Remember, building a SaaS application is a complex task that involves many components. Filament can be a part of the solution, especially for the admin panel, but you'll need to carefully plan and implement the other aspects of your SaaS, including multi-tenancy, subscription billing, and user management.