Download the PHP package ferdiunal/nova-shield without Composer
On this page you can find all versions of the php package ferdiunal/nova-shield. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ferdiunal/nova-shield
More information about ferdiunal/nova-shield
Files in ferdiunal/nova-shield
Package nova-shield
Short Description A Laravel Nova package to manage permissions and roles.
License MIT
Informations about the package nova-shield
Nova Shield - WIP
Nova Shield simplifies permission management for your Laravel Nova resources using Spatie Permission. Easily grant or revoke access to specific resources and actions, streamlining your workflow and improving security.
Installation
Configuration
Optionally, you can publish the configuration file using this command:
In the config file, you can control resource permissions by specifying the resources parameter with either the path to the Nova resources folder or a string class path.
For example, in the code below, we define the resources and their corresponding policies:
Show Code
Custom Menu Configuration
The main purpose of the package was to manage permissions for Nova Resources, but I realized there was a need for Custom Menu support as well. The necessary development has been completed. You can refer to the usage below for implementing Custom Menus.
Then edit App\Nova\Resource.php
file as follows.
Teams Support
I assume you have done the Teams integration for Spatie Permission and you can follow the setup below for NovaShield.
Model Integrations
Teams feature differs in each project, please fill in the relevant method according to your project.
Add Team Field
Considering that the Teams feature will differ in each project, you need to add the team field yourself.
Add Middleware to Nova Routes
Add TeamMiddleware to nova routes
Commands
The package contains two different commands. The first command checks whether the Super Admin role exists, creates it if it doesn’t, and assigns permissions to the resources specified in the configuration file. The second command is used to assign the Super Admin role to users.
Sync Super Admin role and permissions command:
Assign Super Admin role to user(s) command:
Hook Sync Permissions
When mapping permissions to roles, upsert is used by default. If you use custom ID types such as UUID or ULID, upsert does not identify these ids. Therefore, you can write and use a query that suits your project needs.
Example hook:
You will then need to replace the class you created in the configuration file with the default.
Example:
ScreenShots
License This package is open-sourced software licensed under the MIT license.
All versions of nova-shield with dependencies
laravel/framework Version ^10.0|^11.0
laravel/nova Version ^4.0
spatie/laravel-permission Version ^6.9