Integration of Filament Admin to nWidart/laravel-modules: Create Admin panels for each Laravel Module
This plugin provides you with a quick and working configuration to install multiple filament admin contexts in your modular laravel app (using laravel-modules).
The goal of this app is to enable you install multiple contexts of Filament Admin per module in your LaravelModules powered app.
For example, if you have two modules (Blog and Pos), you should be able to have filament installed in each module with separate resources as below:
http://yoururl/blog/admin
http://yoururl/pos/admin
http://yoururl/pos/admin2
or whichever path you configure for that context.Each of the above directories should have their own distinct Pages, Resources and Widgets. Each of them also has a config under the module's Config folder allowing you to customize a number of parameters per context, e.g the path
.
Additionally, each of these can have its own customized login page which redirects back to the module.
You can read more about Multiple Context for Filament Here.
If this is your goal, then you are in the right place.
Before you proceed, this guide assumes that you have configured your app fully to work with Laravel Modules. If you haven't, follow the Laravel Modules Docs before proceeding.
You can install the package via composer:
composer require savannabits/filament-modules
To generate a new Filament Context, use the module:make-filament-context
command.
You can run php artisan module:make-filament-context -h
to see the expected arguments.
#Option 1: Pick an existing module to use first, then run the command (similar to other laravel-modules commands)php artisan module:use Blogphp artisan module:make-filament-context Filament # This will create the Filament context inside the blog module. # Option 2: Pass the Module name as an argument. If the module does not exist, it will be automatically created.php artisan module:make-filament-context Filament Blog # This will create the Filament context inside the blog module.
The configuration for each of the generated contexts will be stored under the module's Config directory, e.g /Modules/Blog/Config/blog-filament.php
in the above case.
You can adjust the config to change several parameters, for example the admin panel path (by default it is admin
).
By default, you should be able to access your admin panel under the url http://yoururl/:yourModule/:yourPathConfig
e.g http://yoururl/blog/admin
in the above case.
If you would like to change the path, you can change it under the corresponding config file.
This package automatically adds each of the generated context's service provider in providers' list in app.php config
. Be sure to remove this Service Provider in case you delete the context.
You may now add filament resources in your FilamentTeams directories. Generate Filament pages/resources/widgets as you normally would. Move them into the context-folder and update the namespace. TODO: We will write a command to automatically generate the resources and pages easily.
Pages:
namespace YourNamespace\Resources; use Savannabits\FilamentModules\Concerns\ContextualPage;use Filament\Pages\Page; class Dashboard extends Page{ use ContextualPage;}
Resources:
namespace YourNamespace\Resources; use Savannabits\FilamentModules\Concerns\ContextualResource;use Filament\Resources\Resource; class UserResource extends Resource{ use ContextualResource;}
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.