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

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

baleethai/nova-permissions
==========================

Laravel Nova Grouped Permissions.

1.0.3(7y ago)019MITPHPPHP &gt;=7.1.0

Since Feb 14Pushed 7y ago1 watchersCompare

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

READMEChangelogDependencies (1)Versions (5)Used By (0)

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

[](#laravel-nova-grouped-permissions)

[![Latest Version on Github](https://camo.githubusercontent.com/e77bd8e0dacc3faa2426af13c1c7c7e0831f2b949496adb14945de22c0dd8fed/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f656d696e69617274732f6e6f76612d7065726d697373696f6e732e7376673f7374796c653d666c6174)](https://packagist.org/packages/eminiarts/nova-permissions)

A Laravel Nova Tool that allows you to group your Permissions into Groups and attach it to Users. It uses Spatie's laravel-permission.

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

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

[![image](https://user-images.githubusercontent.com/3426944/50086531-ae0dbb80-01fd-11e9-835f-f65bba2c0a7b.png)](https://user-images.githubusercontent.com/3426944/50086531-ae0dbb80-01fd-11e9-835f-f65bba2c0a7b.png)

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

[](#installation)

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

```
composer require eminiarts/nova-permissions
```

Publish the Migration with the following command:

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

Migrate the Database:

```
php artisan migrate
```

Next up, 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 [
        // ...
        \Baleethai\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', \Baleethai\NovaPermissions\Nova\Role::class),
        MorphToMany::make('Permissions', 'permissions', \Baleethai\NovaPermissions\Nova\Permission::class),
    ];
}
```

A new menu item called **Permissions &amp; Roles** will appear in your Nova app after installing this package.

Permissions with Groups
-----------------------

[](#permissions-with-groups)

### Detail View

[](#detail-view)

[![image](https://user-images.githubusercontent.com/3426944/50088581-b1a44100-0203-11e9-8ae8-c21cc0b02393.png)](https://user-images.githubusercontent.com/3426944/50088581-b1a44100-0203-11e9-8ae8-c21cc0b02393.png)

### Edit View

[](#edit-view)

[![image](https://user-images.githubusercontent.com/3426944/50088682-0051db00-0204-11e9-8201-1ac4b57f0631.png)](https://user-images.githubusercontent.com/3426944/50088682-0051db00-0204-11e9-8201-1ac4b57f0631.png)

### Database Seeding

[](#database-seeding)

Publish our Seeder with the following command:

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

```

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 and change the email for the Super-Admin:

```
