← Back to Plugins
  • Laravel Modules

Laravel Modules

Plugin information

by Samson Maosa • 12 stars

Admin panel Kit

Integration of Filament Admin to nWidart/laravel-modules: Create Admin panels for each Laravel Module

Support

#laravel-modules on Discord

Views

2636

License

MIT

Documentation

Filament Laravel Modules

img_2.png img_3.png

This plugin provides you with a quick and working configuration to install multiple filament admin contexts in your modular laravel app (using laravel-modules).

Goal

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:

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.

Installation

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

Usage

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 Blog
php 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.

Directory Structure of the generated module:

img.png

Config:

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).

The context's admin panel path

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.

The Context's Service Provider

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.

Adding Pages/Resources to Module 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.

ContextualPage & ContextualResource traits

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;
}

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.