PHPackages                             graphene-ict/nova-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. graphene-ict/nova-permissions

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

graphene-ict/nova-permissions
=============================

Nova Permissions tool based on spatie permissions

v1.0.2(3y ago)95.5k7[1 issues](https://github.com/GrapheneICT/nova-permissions/issues)MITPHPPHP ^7.3|^8.0|^8.1

Since Jul 6Pushed 3y ago2 watchersCompare

[ Source](https://github.com/GrapheneICT/nova-permissions)[ Packagist](https://packagist.org/packages/graphene-ict/nova-permissions)[ RSS](/packages/graphene-ict-nova-permissions/feed)WikiDiscussions master Synced 3w ago

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

Laravel Nova Permissions
========================

[](#laravel-nova-permissions)

Nova Permissions tool based on spatie permissions

We have a Migration, Seed, Policy and Resource ready for a good Authorization Experience.

[![image](https://user-images.githubusercontent.com/22980168/86119518-ec628700-bad2-11ea-9724-03f25eaba41e.PNG)](https://user-images.githubusercontent.com/22980168/86119518-ec628700-bad2-11ea-9724-03f25eaba41e.PNG)

1. [Installation](#Installation)
    - [Database Migration](#database-migration)
    - [Configuration](#configuration)
    - [Database Seeding](#database-seeding)
2. [Permissions](#permissions)
    - [Detail View](#detail-view)
    - [Edit View](#edit-view)
    - [Create a Model Policy](#create-a-model-policy)
    - [Scope Resource for User](#scope-resource-for-user)
3. [Customization](#customization)
    - [Use your own Resources](#use-your-own-resources)
4. [Credits](#credits)

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

[](#installation)

You can install the package in to a Laravel app that uses [Nova](https://nova.laravel.com) via composer:

```
composer require graphene-ict/nova-permissions
```

### Database Migration

[](#database-migration)

Publish the Migration with the following command:

```
php artisan vendor:publish --provider="GrapheneICT\NovaPermissions\ToolServiceProvider" --tag="migrations"
```

Migrate the Database:

```
php artisan migrate
```

### Configuration

[](#configuration)

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 [
        // ...
        new \GrapheneICT\NovaPermissions\NovaPermissions(),
    ];
}
```

Finally, add `MorphToMany` fields to you `app/Nova/User` resource:

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

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

Add the Spatie\\Permission\\Traits\\HasRoles trait to your User model(s):

```
use Illuminate\Foundation\Auth\User as Authenticatable;
use Spatie\Permission\Traits\HasRoles;

class User extends Authenticatable
{
    use HasRoles;

    // ...
}
```

### Database Seeding

[](#database-seeding)

Publish our Seeder with the following command:

```
php artisan vendor:publish --provider="GrapheneICT\NovaPermissions\ToolServiceProvider" --tag="seeds"

```

Before you do any seeding admin email parametar in your env

```
NOVA_PERMISSION_ADMIN_EMAIL = your@email.com
```

This is just an example on how you could seed your Database with Roles and Permissions. Modify `RolesAndPermissionsSeeder.php` in `database/seeds`. List all your Models you want to have Permissions for in the `$collection` Array. Create a role and attach permissions to it:

```
class RolesAndPermissionsSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        // Reset cached roles and permissions
        app()[PermissionRegistrar::class]->forgetCachedPermissions();

        $collection = collect([
            User::class,
            Role::class,
            Permission::class,
            // ... // List all your Models you want to have Permissions for.
        ]);

        $adminEmail = env('NOVA_PERMISSION_ADMIN_EMAIL', null);

        if (is_null($adminEmail)) {
            throw new \InvalidArgumentException('Email parameter must be provided!');
        }

        // Create an Admin Role and assign all Permissions
        $role = Role::create(['name' => 'admin']);
        $role->givePermissionTo(Permission::all());

       // Give User Admin Role
         $user = User::whereEmail($adminEmail)->first(); // Change this to your email.
         $user->assignRole('admin');
    }
}
```

Now you can seed the Database. Add `$this->call(RolesAndPermissionsSeeder::class);` to the `DatabaseSeeder`.

> **Note**: If this doesn't work, run `composer dumpautoload` to autoload the Seeder.

Permissions
-----------

[](#permissions)

### Detail View

[](#detail-view)

[![grap1](https://user-images.githubusercontent.com/22980168/86581659-aef17400-bf80-11ea-897d-f00952e1b2cc.PNG)](https://user-images.githubusercontent.com/22980168/86581659-aef17400-bf80-11ea-897d-f00952e1b2cc.PNG)

### Edit View

[](#edit-view)

[![grap2](https://user-images.githubusercontent.com/22980168/86581690-bf095380-bf80-11ea-85fc-3f06d2873547.PNG)](https://user-images.githubusercontent.com/22980168/86581690-bf095380-bf80-11ea-85fc-3f06d2873547.PNG)

### Create a Model Policy

[](#create-a-model-policy)

You can extend `GrapheneICT\NovaPermissions\Policies\Policy` and have a very clean Model Policy that works with Nova.

For Example: Create a new User Policy with `php artisan make:policy UserPolicy` with the following code:

```
class UserPolicy extends Policy
{
    /**
     * The Permission key the Policy corresponds to.
     *
     * @var string
     */
    public static $key = 'users';
}
```

It should now work as exptected. Just create a Role, modify its Permissions and the Policy should take care of the rest.

> **Note**: Don't forget to add your Policy to your `$policies` in `App\Providers\AuthServiceProvider`.

> **Note**: Only extend the Policy if you have created your Permissions according to our Seeding Example. Otherwise, make sure to have `view users, view own users, manage users, manage own users, restore users,  forceDelete users` as Permissions in your Table in order to extend our Policy.

> `view own users` is superior to `view users` and allows the User to only view his own Users.

> `manage own users` is superior to `manage users` and allows the User to only manage his own Users.

### Scope Resource for User

[](#scope-resource-for-user)

If you use our Policy and Seeder, the user will still be able to see other Entries. In order to only **allow a User to view his own Entries** and no others, you can extens our `GrapheneICT\NovaPermissions\Nova\ResourceForUser` Class like this:

```
class User extends ResourceForUser
{
    //...
}
```

> **Note**: ResourceForUser assumes the Resource has a `user_id` column in the Database. If you are using another column, feel free to copy the contents of the Resource and modify it.

Customization
-------------

[](#customization)

### Use your own Resources

[](#use-your-own-resources)

If you want to use your own resource classes, you can define them when you register the tool:

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

// ...

public function tools()
{
    return [
        // ...
        \GrapheneICT\NovaPermissions\NovaPermissionTool::make()
            ->roleResource(Role::class)
            ->permissionResource(Permission::class),
    ];
}
```

Credits
-------

[](#credits)

This Package is inspired by [eminiarts/nova-permission](https://novapackages.com/packages/eminiarts/nova-permissions)

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 66.7% 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 ~405 days

Total

3

Last Release

1371d ago

PHP version history (2 changes)v1.0.0PHP &gt;= 7.2.0

v1.0.2PHP ^7.3|^8.0|^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/8160951a0cd8e658add59bc36c59497d410ac3a82ab800aa6cd40b54f188f287?d=identicon)[graphene](/maintainers/graphene)

---

Top Contributors

[![smskin](https://avatars.githubusercontent.com/u/3227797?v=4)](https://github.com/smskin "smskin (4 commits)")[![jstojiljkovic](https://avatars.githubusercontent.com/u/22980168?v=4)](https://github.com/jstojiljkovic "jstojiljkovic (1 commits)")[![TenTail](https://avatars.githubusercontent.com/u/16322298?v=4)](https://github.com/TenTail "TenTail (1 commits)")

---

Tags

laravellaravel-novaphpvue

### Embed Badge

![Health badge](/badges/graphene-ict-nova-permissions/health.svg)

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

###  Alternatives

[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k3.5M118](/packages/bezhansalleh-filament-shield)[althinect/filament-spatie-roles-permissions

3461.1M10](/packages/althinect-filament-spatie-roles-permissions)[nasirkhan/laravel-starter

A CMS like modular Laravel starter project.

1.4k2.7k](/packages/nasirkhan-laravel-starter)[chiiya/filament-access-control

Admin user, role and permission management for Laravel Filament

21851.1k](/packages/chiiya-filament-access-control)[binary-cats/laravel-rbac

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

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

PHPackages © 2026

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