PHPackages                             gabrielesbaiz/nova-spatie-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. gabrielesbaiz/nova-spatie-permissions

ActiveLibrary

gabrielesbaiz/nova-spatie-permissions
=====================================

A Laravel Nova tool for the Spatie Permission package

1.0.0(1y ago)02.5k↑850%MITPHPPHP ^8.0CI passing

Since Mar 3Pushed 12mo ago1 watchersCompare

[ Source](https://github.com/gabrielesbaiz/nova-spatie-permissions)[ Packagist](https://packagist.org/packages/gabrielesbaiz/nova-spatie-permissions)[ Docs](https://github.com/gabrielesbaiz/nova-spatie-permissions)[ GitHub Sponsors]()[ RSS](/packages/gabrielesbaiz-nova-spatie-permissions/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (10)Versions (3)Used By (0)

NovaSpatiePermissions
=====================

[](#novaspatiepermissions)

[![Latest Version on Packagist](https://camo.githubusercontent.com/9fb72bdfa1005f142faa43c8828083ecb79c82f65ce95277262ec8375ac4ac98/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6761627269656c65736261697a2f6e6f76612d7370617469652d7065726d697373696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/gabrielesbaiz/nova-spatie-permissions)[![Total Downloads](https://camo.githubusercontent.com/c591195c945772a133374dab2ffd8beac70b19032d95a3bf06ba47342a62a90d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6761627269656c65736261697a2f6e6f76612d7370617469652d7065726d697373696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/gabrielesbaiz/nova-spatie-permissions)

A Laravel Nova tool for the Spatie Permission package.

Original code from [moroneyio/novaspatiepermissions](https://github.com/moroneyio/novaspatiepermissions)

Features
--------

[](#features)

- ✅ Manage roles and permissions on the Nova dashboard
- ✅ Use permissions based authorization for Nova resources

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require gabrielesbaiz/nova-spatie-permissions
```

Next, if you do not have package discovery enabled, you need to register the provider in the `config/app.php` file.

```
'providers' => [
    ...,
    Gabrielesbaiz\NovaSpatiePermissions\NovaSpatiePermissionsServiceProvider::class,
]
```

Next, you must register the tool with Nova. This is typically done in the `tools` method of the `NovaServiceProvider`.

```
// in app/Providers/NovaServiceProvider.php
use Gabrielesbaiz\NovaSpatiePermissions\Novaspatiepermissions;

public function tools()
{
    return [
        // ...
        Novaspatiepermissions::make(),
    ];
}
```

Next, add `MorphToMany` fields to your `app/Nova/User` resource:

```
use Laravel\Nova\Fields\MorphToMany;

public function fields(Request $request)
{
    return [
        // ...
        MorphToMany::make('Roles', 'roles', \Gabrielesbaiz\NovaSpatiePermissions\Role::class),
        MorphToMany::make('Permissions', 'permissions', \Gabrielesbaiz\NovaSpatiePermissions\Permission::class),
    ];
}
```

Finally, add the `ForgetCachedPermissions` class to your `config/nova.php` middleware like so:

```
// in config/nova.php
'middleware' => [
	'web',
	Authenticate::class,
	DispatchServingNovaEvent::class,
	BootTools::class,
	Authorize::class,
	 \Gabrielesbaiz\NovaSpatiePermissions\ForgetCachedPermissions::class,
],
```

Localization
------------

[](#localization)

You can use the artisan command line tool to publish localization files:

```
php artisan vendor:publish --provider=" \Gabrielesbaiz\NovaSpatiePermissions\NovaPermissionServiceProvider"
```

Usage
-----

[](#usage)

```
$novaSpatiePermissions = new Gabrielesbaiz\NovaSpatiePermissions();
echo $novaSpatiePermissions->echoPhrase('Hello, Gabrielesbaiz!');
```

Permissions Based Authorization for Nova Resources
--------------------------------------------------

[](#permissions-based-authorization-for-nova-resources)

By default, Laravel Nova uses Policy based authorization for Nova resources. If you are using the Spatie Permission library, it is very likely that you would want to swap this out to permission based authorization without the need to define Authorization policies.

To do so, you can use the `PermissionsBasedAuthTrait` and define a `permissionsForAbilities` static array property in your Nova resource class like so:

```
// in app/Nova/YourNovaResource.php

class YourNovaResource extends Resource
{
    use \Gabrielesbaiz\NovaSpatiePermissions\PermissionsBasedAuthTrait;

    public static $permissionsForAbilities = [
      'all' => 'manage products',
    ];
}
```

The example above means that all actions on this resource can be performed by users who have the "manage products" permission. You can also define separate permissions for each action like so:

```
    public static $permissionsForAbilities = [
      'viewAny' => 'view products',
      'view' => 'view products',
      'create' => 'create products',
      'update' => 'update products',
      'delete' => 'delete products',
      'restore' => 'restore products',
      'forceDelete' => 'forceDelete products',
      'addAttribute' => 'add product attributes',
      'attachAttribute' => 'attach product attributes',
      'detachAttribute' => 'detach product attributes',
    ];
```

### Relationships

[](#relationships)

To allow your users to specify a relationship on your model, you will need to add another permission on the Model. For example, if your `Product` belongs to `User`, add the following permission on `app/Nova/User.php`. :

```
    public static $permissionsForAbilities = [
      'addProduct' => 'add user on products'
    ];
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Joshua](https://github.com/moroneyio)
- [Gabriele Sbaiz](https://github.com/gabrielesbaiz)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance47

Moderate activity, may be stable

Popularity22

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

441d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/97040fb60637d4b81897347524bc9343ffa6b978d4b19c0c28ea0823e2a1752b?d=identicon)[gabrielesbaiz](/maintainers/gabrielesbaiz)

---

Top Contributors

[![gabrielesbaiz](https://avatars.githubusercontent.com/u/22818698?v=4)](https://github.com/gabrielesbaiz "gabrielesbaiz (4 commits)")

---

Tags

laravelGabriele Sbaiznova-spatie-permissions

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/gabrielesbaiz-nova-spatie-permissions/health.svg)

```
[![Health](https://phpackages.com/badges/gabrielesbaiz-nova-spatie-permissions/health.svg)](https://phpackages.com/packages/gabrielesbaiz-nova-spatie-permissions)
```

###  Alternatives

[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[binary-cats/laravel-rbac

Laravel enum-backed RBAC extension of spatie/laravel-permission

7730.4k](/packages/binary-cats-laravel-rbac)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
