Download the PHP package sweet1s/moonshine-roles-permissions without Composer
On this page you can find all versions of the php package sweet1s/moonshine-roles-permissions. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sweet1s/moonshine-roles-permissions
More information about sweet1s/moonshine-roles-permissions
Files in sweet1s/moonshine-roles-permissions
Package moonshine-roles-permissions
Short Description Moonshine Role and Permission management
License MIT
Homepage https://moonshine-laravel.com/
Informations about the package moonshine-roles-permissions
MoonShine Roles-Permissions
Description
This package is an extension exclusively designed for the MoonShine Admin Panel, building upon the functionality of the Spatie Laravel Permissions package. The primary purpose of this extension is to streamline role-based access control (RBAC) within the MoonShine Admin Panel. By utilizing this package, you can efficiently assign permissions to roles and then grant those roles to users, simplifying the process of managing permissions on a role-based level rather than individually assigning them to each user.
Requirements
Moonshine: v2.0+
Spatie Laravel Permissions: v6.0+
Features
- [x] Role-Based Access Control (RBAC): Enhance your MoonShine Admin Panel with a comprehensive role-based permission system, allowing you to group users with similar permissions into roles and manage access more efficiently.
- [x] Role Assignment: Seamlessly associate permissions with roles, making it effortless to define the access rights for specific groups of users.
- [x] Bulk Role Assignment: Grant multiple users the same role simultaneously, reducing the manual effort required to manage permissions across large user bases.
- [x] Seamless Integration: The package seamlessly integrates with the MoonShine Admin Panel and extends the capabilities of the Spatie Laravel Permissions package specifically for this panel.
Important
Before using the package, it is crucial to understand that you need to use a different user model instead
of "MoonShineUser
" and use the table users
. The package requires the utilization of the Spatie Laravel.
Installation
-
Install the Spatie Laravel Permissions package and follow the instructions in the documentation to set up the package correctly.
-
Install the package via composer:
-
In the MoonShine config file, change the user model to the default User model or the model you want to use for the admin panel.
-
In the
Spatie permission config file
, change the models.role toApp\Models\Role::class
(Model need extend \Spatie\Permission\Models\Role), like this: -
For your Role model, add the following:
-
For the user model, add the following:
-
Run the following command to install the package and follow the installation steps:
-
(Optional) Create a user with new modal and assign automatically the role "Super Admin" to it.
- Add to your
RoleResource
traitWithPermissionsFormComponent
:
Add to your UserResource
trait WithRoleFormComponent
:
Or add new MoonShine resource to your MoonShineServiceProvider file, like this (you can use other UserResource):
Dynamic Items on Menu
If you want to add dynamic items to the menu that depend on the role right, you just need to add an array of menus to the MenuRBAC::menu() adapter.
Usage
You can use the following command to generate a resource and permissions at the same time:
- For Resource, add the following:
Custom Permissions
If you want to create custom permissions, you can use the following command:
or in PermissionResource
Localization
The package comes with default translation files in English, Russian and Romanian. If you want to customise the translations, you can publish the package translation files in your project using the following command:
Commands documentation
How does it look in the Admin Panel ?
Role Resource | User Resource |
---|---|
All versions of moonshine-roles-permissions with dependencies
ext-curl Version *
ext-json Version *
lee-to/laravel-package-command Version ^0.9.1
spatie/laravel-permission Version ^6.2