-
Notifications
You must be signed in to change notification settings - Fork 164
Developer 8.0 Upgrade Guide
There are some changes in 8.0 for developers
-
Now, we are using
spatie/laravel-permissionwithbezhansalleh/filament-shieldand Laravel Policies, providing more in-depth permissions on each model (likeview_any,view,create,delete,edit,force_delete...). -
Access to the admin interface is allowed if the user has the
super_adminor theadminrole or thepage_Dashboardpermission. To check if a user can access the admin interface, use$user->hasAdminAccess()which returns a boolean. You can also use Laravel Gates via$user->can('access_admin'). -
When creating a new Model (a core one), you need to create permissions related to this model using
php artisan shield:generate --all --ignore-existing-policies -n. If your model follows the laravel conventions the policy will be autodiscovered, otherwise you need to register it. See https://laravel.com/docs/11.x/authorization#registering-policies. Note: always test a non authorized user can't access the resource. -
The
abilitymiddleware does not exist anymore. To check if a user has admin access with a middleware, use the following middleware:can:access_admin. If you wanna check if a user can view modules (typically for non-filament compatible modules access) please use thecan:view_modulemiddleware. -
To prevent any kind of privilege escalation only super admins are allowed to view/create/edit/delete/give/remove roles
-
To access the modules dashboard, a user requires the
view_modulepermission. -
Every model in each module may have a policy within the
Modules\ModuleName\Policiesnamespace. -
If you want to generate these policies automatically please use
php artisan shield:generate --all --ignore-existing-policies -n -
These policies, in conjunction with the auto-discovery feature of Filament Shield, will generate new permissions that can be assigned to any role on the role page. Same thing goes for policy discovery, see https://laravel.com/docs/11.x/authorization#registering-policies
- With the upgrade to the new permissions system, modules can't be compatible both for Filament and non-Filament PHPVMS installs. However they just need some permissions changes (middlewares) to be 100% compatible. A module using the old admin UI can work with filament (as long as this module uses plain html and not the
Form::helper).
- Modules will now have their own Filament Panel, meaning they'll have a different sidebar, etc.
- To create a Filament Panel for your module, use the following command:
php artisan module:setup-filament yourModuleName - Then create filament resources/pages/widgets for your module using the
php artisan make:filament-...command. You'll be prompted for the panel, and you just have to choose youryourModuleName::admin. - For development, refer to the Filament Documentation and the Livewire Documentation.
- In order to enable activity log in your module, you need to configure your module's Models and PanelProvider. For models please look at some core models like User and for the panel provider you need to add :
->bootUsing(function () {
activity()->enableLogging();
})- Since version 9, Laravel comes by default with Vite instead of Webpack.
- Initially, upgrading to Vite was not possible due to the constraints of the previous admin template. However, now, with Filament, we can and have successfully done it.
- To compile your assets, use
npm run buildfor production ornpm run devfor local development. - Note: Vite includes hot reloading of the page with local development, meaning your page will automatically reload and assets recompile when you change something in a blade view/js file...
- In order to improve a lot performances please run:
php artisan filament:optimize,php artisan optimizeafter each deployments.