PHPackages                             hassni/laravel-nova-permission - 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. hassni/laravel-nova-permission

ActiveLibrary

hassni/laravel-nova-permission
==============================

A Laravel Nova tool for Spatie's Permission library.

2.0(4y ago)19MITPHPPHP &gt;=7.1.0

Since Nov 10Pushed 4y agoCompare

[ Source](https://github.com/azeemhassni/laravel-nova-permission)[ Packagist](https://packagist.org/packages/hassni/laravel-nova-permission)[ RSS](/packages/hassni-laravel-nova-permission/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (1)Dependencies (1)Versions (5)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/23ddb33963b200680d9064fa35a9263a5eb31cb13f91586c3785325605fbdb81/68747470733a2f2f706f7365722e707567782e6f72672f696e73656e7365616e616c79746963732f6c61726176656c2d6e6f76612d7065726d697373696f6e2f6c6963656e7365)](https://packagist.org/packages/insenseanalytics/laravel-nova-permission)[![Latest Stable Version](https://camo.githubusercontent.com/79859bdd6f58f675902578ceeb3ba16bbca0a9a4ea3e76afb232f10af6946cf7/68747470733a2f2f706f7365722e707567782e6f72672f696e73656e7365616e616c79746963732f6c61726176656c2d6e6f76612d7065726d697373696f6e2f762f737461626c65)](https://packagist.org/packages/insenseanalytics/laravel-nova-permission)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/e4f41c505feaead7bd4dd3992998881a6caf091e5402c16bf06a42099c525c33/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f696e73656e7365616e616c79746963732f6c61726176656c2d6e6f76612d7065726d697373696f6e2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/insenseanalytics/laravel-nova-permission/?branch=master)[![Total Downloads](https://camo.githubusercontent.com/c9c71f9882cfad2875171d7648ee11f59fe1559be4960172dde9a048db8753d3/68747470733a2f2f706f7365722e707567782e6f72672f696e73656e7365616e616c79746963732f6c61726176656c2d6e6f76612d7065726d697373696f6e2f646f776e6c6f616473)](https://packagist.org/packages/insenseanalytics/laravel-nova-permission)

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 of the backup tool](https://camo.githubusercontent.com/5f3323f0df623dfb9843cd097c8417f6574764a8d3db0fce391cfd955784b718/68747470733a2f2f696e73656e7365616e616c79746963732e6769746875622e696f2f7075626c69632d6173736574732f6c61726176656c2d6e6f76612d7065726d697373696f6e2f6e6f76612d7065726d697373696f6e2d73637265656e73686f742e706e67)](https://camo.githubusercontent.com/5f3323f0df623dfb9843cd097c8417f6574764a8d3db0fce391cfd955784b718/68747470733a2f2f696e73656e7365616e616c79746963732e6769746875622e696f2f7075626c69632d6173736574732f6c61726176656c2d6e6f76612d7065726d697373696f6e2f6e6f76612d7065726d697373696f6e2d73637265656e73686f742e706e67)

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

[](#requirements--dependencies)

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

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

[](#installation)

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

```
composer require insenseanalytics/laravel-nova-permission
```

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

```
'providers' => [
    ...,
    Insenseanalytics\LaravelNovaPermission\NovaPermissionServiceProvider::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

public function tools()
{
    return [
        // ...
        \Insenseanalytics\LaravelNovaPermission\LaravelNovaPermission::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', \Insenseanalytics\LaravelNovaPermission\Role::class),
        MorphToMany::make('Permissions', 'permissions', \Insenseanalytics\LaravelNovaPermission\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,
	\Insenseanalytics\LaravelNovaPermission\ForgetCachedPermissions::class,
],
```

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

[](#localization)

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

```
php artisan vendor:publish --provider="Insenseanalytics\LaravelNovaPermission\NovaPermissionServiceProvider"
```

Using Custom Role/Permission Resource Classes
---------------------------------------------

[](#using-custom-rolepermission-resource-classes)

If you want to use custom resource classes you can define them when you register a tool:

```
// in app/Providers/NovaServiceProvider.php

public function tools()
{
    return [
        // ...
        \Insenseanalytics\LaravelNovaPermission\LaravelNovaPermission::make()
            ->roleResource(CustomRole::class)
            ->permissionResource(CustomPermission::class),
    ];
}
```

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 \Insenseanalytics\LaravelNovaPermission\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 and will be fully credited as long as you use PSR-2, explain the issue/feature that you want to solve/add and back your code up with tests. Happy coding!

License
-------

[](#license)

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

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

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

Every ~317 days

Total

4

Last Release

1788d ago

Major Versions

v0.1.2 → v1.02020-10-07

v1.0 → 2.02021-06-20

### Community

Maintainers

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

---

Top Contributors

[![paras-malhotra](https://avatars.githubusercontent.com/u/16099046?v=4)](https://github.com/paras-malhotra "paras-malhotra (20 commits)")[![azeemhassni](https://avatars.githubusercontent.com/u/6503258?v=4)](https://github.com/azeemhassni "azeemhassni (3 commits)")[![flashadvocate](https://avatars.githubusercontent.com/u/7848492?v=4)](https://github.com/flashadvocate "flashadvocate (1 commits)")

---

Tags

spatielaravelnovalaravel-permission

### Embed Badge

![Health badge](/badges/hassni-laravel-nova-permission/health.svg)

```
[![Health](https://phpackages.com/badges/hassni-laravel-nova-permission/health.svg)](https://phpackages.com/packages/hassni-laravel-nova-permission)
```

###  Alternatives

[insenseanalytics/laravel-nova-permission

A Laravel Nova tool for Spatie's Permission library.

7549.0k](/packages/insenseanalytics-laravel-nova-permission)[itsmejoshua/novaspatiepermissions

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

30262.5k](/packages/itsmejoshua-novaspatiepermissions)

PHPackages © 2026

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