PHPackages                             sweet1s/moonshine-roles-permissions - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. sweet1s/moonshine-roles-permissions

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

sweet1s/moonshine-roles-permissions
===================================

Moonshine Role and Permission management

4.0.0(7mo ago)2617.3k↓27.1%10[6 issues](https://github.com/SWEET1S/moonshine-roles-permissions/issues)MITPHPPHP ^8.2|^8.3|^8.4

Since Jul 21Pushed 7mo ago4 watchersCompare

[ Source](https://github.com/SWEET1S/moonshine-roles-permissions)[ Packagist](https://packagist.org/packages/sweet1s/moonshine-roles-permissions)[ Docs](https://moonshine-laravel.com/)[ RSS](/packages/sweet1s-moonshine-roles-permissions/feed)WikiDiscussions 3.x Synced 3d ago

READMEChangelog (10)Dependencies (8)Versions (32)Used By (0)

MoonShine Roles-Permissions
---------------------------

[](#moonshine-roles-permissions)

### Description

[](#description)

This package is an extension exclusively designed for the [MoonShine Admin Panel](https://github.com/moonshine-software/moonshine), building upon the functionality of the [Spatie Laravel Permissions](https://github.com/spatie/laravel-permission) 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.

[![Total Downloads](https://camo.githubusercontent.com/5271352744eccd8c7a3ec2724185971300a9dd9dfb54292e396fd604f18c5a14/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f737765657431732f6d6f6f6e7368696e652d726f6c65732d7065726d697373696f6e73)](https://packagist.org/packages/sweet1s/moonshine-roles-permissions)[![Latest Stable Version](https://camo.githubusercontent.com/0c421d7fbb7d9cd175e3ef66c82652751f47c991f395882fa64e9fe3d7d94d3c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f737765657431732f6d6f6f6e7368696e652d726f6c65732d7065726d697373696f6e73)](https://packagist.org/packages/sweet1s/moonshine-roles-permissions)[![License](https://camo.githubusercontent.com/ddaf3862a8f7b365b27bcc10c885140a834f3fe33e9b808ce8c48f88bca52e0a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f737765657431732f6d6f6f6e7368696e652d726f6c65732d7065726d697373696f6e73)](https://packagist.org/packages/sweet1s/moonshine-roles-permissions)

 [![Laravel 9+](https://camo.githubusercontent.com/67ff25342790de50f83c6313acb28d5fdd1d7931a63bf481f21ea769b7b1ca1c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d31302b2d4646324432303f7374796c653d666f722d7468652d6261646765266c6f676f3d6c61726176656c)](https://laravel.com) [![PHP 8+](https://camo.githubusercontent.com/e0f3f4481fef29b2320c4adf7fa7b4da977fd87bb8b642832ebe759cd73040bf/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312b2d3737374242343f7374796c653d666f722d7468652d6261646765266c6f676f3d706870)](https://laravel.com) [![Moonshine Admin Panel](https://camo.githubusercontent.com/a5a1cb11e165694625116bd92055cd7981c92d07025b0dff61de13f2cbf1af4d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4d6f6f6e7368696e652d322e302b2d3142323533423f7374796c653d666f722d7468652d6261646765)](https://github.com/moonshine-software/moonshine)

---

> ### Requirements
>
> [](#requirements)
>
> Moonshine: v3.0+
>
> Spatie Laravel Permissions: v6.0+

---

Features
--------

[](#features)

- 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.
- Role Assignment: Seamlessly associate permissions with roles, making it effortless to define the access rights for specific groups of users.
- Bulk Role Assignment: Grant multiple users the same role simultaneously, reducing the manual effort required to manage permissions across large user bases.
- 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
---------

[](#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
------------

[](#installation)

1. Install the [Spatie Laravel Permissions](https://github.com/spatie/laravel-permission) package and follow the instructions in the [documentation](https://spatie.be/docs/laravel-permission/v6/installation-laravel) to set up the package correctly.
2. Install the package via composer:

```
composer require sweet1s/moonshine-roles-permissions
```

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

```
return [
    // ...
    'auth' => [
        // ...
        'model' => \App\Models\User::class,
        // ...
    ],
    // ...
];
```

4. In the `Spatie permission config file`, change the models.role to `App\Models\Role::class` (Model need extend \\Spatie\\Permission\\Models\\Role), like this:

```
'models' => [
    // ...
    'role' => App\Models\Role::class,
],
```

5. For your Role model, add the following:

```
