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

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

dmitriy-robu/permissions-nova-spatie
====================================

Laravel Nova tool for managing spaties roles/permissions in laravel's nova package.

0517PHP

Since Jul 21Pushed 2y agoCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

A Laravel Nova tool for the Spatie Permission package
=====================================================

[](#a-laravel-nova-tool-for-the-spatie-permission-package)

[![License](https://camo.githubusercontent.com/670af82f03db2065fba499c8cbdf14f15f88bdca8d5c4e15a6e9a5c680bbbc48/68747470733a2f2f706f7365722e707567782e6f72672f6974736d656a6f736875612f6e6f76617370617469657065726d697373696f6e732f6c6963656e7365)](https://packagist.org/packages/insenseanalytics/laravel-nova-permission)[![Latest Stable Version](https://camo.githubusercontent.com/a50508c69d2a534ece74eb6597f76cf70ca2315a619389bcb095ce254bd90685/68747470733a2f2f706f7365722e707567782e6f72672f6974736d656a6f736875612f6e6f76617370617469657065726d697373696f6e732f762f737461626c65)](https://packagist.org/packages/itsmejoshua/novaspatiepermissions)[![Total Downloads](https://camo.githubusercontent.com/a59373886208675db7bc7a4e57fc1d9c9e853710a9c21ada2264b8e0e7eafcd8/68747470733a2f2f706f7365722e707567782e6f72672f6974736d656a6f736875612f6e6f76617370617469657065726d697373696f6e732f646f776e6c6f616473)](https://packagist.org/packages/itsmejoshua/novaspatiepermissions)

This [Nova](https://nova.laravel.com) tool lets you:

- manage roles and permissions on the Nova dashboard
- use permissions based authorization for Nova resources

Screenshots
-----------

[](#screenshots)

[![screenshot](https://camo.githubusercontent.com/77ec3c49b0b5077fbb9eb6444a9def7fb51318cc83952c7a53294ceb1f81c4ef/68747470733a2f2f6974736d656a6f736875612e6f63686f737465642e61752d737964312e7570636c6f75646f626a656374732e636f6d2f4e6f76615370617469655065726d697373696f6e732e706e67)](https://camo.githubusercontent.com/77ec3c49b0b5077fbb9eb6444a9def7fb51318cc83952c7a53294ceb1f81c4ef/68747470733a2f2f6974736d656a6f736875612e6f63686f737465642e61752d737964312e7570636c6f75646f626a656374732e636f6d2f4e6f76615370617469655065726d697373696f6e732e706e67)

Requirements &amp; Dependencies
-------------------------------

[](#requirements--dependencies)

There are no PHP dependencies except the [Laravel Nova](https://nova.laravel.com) v4 package and the [Spatie Permission](https://github.com/spatie/laravel-permission) v5 package.

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

[](#installation)

You can install this tool into a Laravel app that uses [Nova](https://nova.laravel.com) via composer:

```
composer require dmitriy-robu/permissions-nova-spatie
```

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

```
'providers' => [
    ...,
    Itsmejoshua\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 Itsmejoshua\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', \Itsmejoshua\Novaspatiepermissions\Role::class),
        MorphToMany::make('Permissions', 'permissions', \Itsmejoshua\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,
	 \Itsmejoshua\Novaspatiepermissions\ForgetCachedPermissions::class,
],
```

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

[](#localization)

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

```
php artisan vendor:publish --provider=" \Itsmejoshua\Novaspatiepermissions\NovaPermissionServiceProvider"
```

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 \Itsmejoshua\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'
    ];
```

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

[](#contributing)

Contributions are welcome, explain the issue/feature that you want to solve/add and back your code up with tests. Happy coding!

License
-------

[](#license)

This package was originally developed by  however they have abandoned the package. The MIT License (MIT). Please see [License File](LICENSE.txt) for more information.

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity21

Early-stage or recently created project

 Bus Factor1

Top contributor holds 56.8% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/fc6a0484905e485847f7d8e14723814ddfcec7c1205336e0f5bf97ed3f6afe58?d=identicon)[telonkor](/maintainers/telonkor)

---

Top Contributors

[![moroneyio](https://avatars.githubusercontent.com/u/78652562?v=4)](https://github.com/moroneyio "moroneyio (21 commits)")[![dmitriy-robu](https://avatars.githubusercontent.com/u/42378060?v=4)](https://github.com/dmitriy-robu "dmitriy-robu (10 commits)")[![popcornrus](https://avatars.githubusercontent.com/u/32881606?v=4)](https://github.com/popcornrus "popcornrus (5 commits)")[![ijpatricio](https://avatars.githubusercontent.com/u/26031459?v=4)](https://github.com/ijpatricio "ijpatricio (1 commits)")

### Embed Badge

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

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

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[league/oauth1-client

OAuth 1.0 Client Library

99698.8M106](/packages/league-oauth1-client)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[league/oauth2-google

Google OAuth 2.0 Client Provider for The PHP League OAuth2-Client

41721.2M118](/packages/league-oauth2-google)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)

PHPackages © 2026

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