{"id":36331255,"url":"https://github.com/insenseanalytics/laravel-nova-permission","last_synced_at":"2026-01-11T12:00:16.858Z","repository":{"id":56991985,"uuid":"156837814","full_name":"insenseanalytics/laravel-nova-permission","owner":"insenseanalytics","description":"A Laravel Nova tool for the Spatie Permission package","archived":false,"fork":false,"pushed_at":"2020-10-07T11:49:54.000Z","size":30,"stargazers_count":76,"open_issues_count":7,"forks_count":33,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-10-02T08:28:27.828Z","etag":null,"topics":["laravel","nova","permissions","spatie"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/insenseanalytics.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-09T09:12:57.000Z","updated_at":"2025-07-31T11:44:10.000Z","dependencies_parsed_at":"2022-08-21T12:20:40.560Z","dependency_job_id":null,"html_url":"https://github.com/insenseanalytics/laravel-nova-permission","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/insenseanalytics/laravel-nova-permission","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/insenseanalytics%2Flaravel-nova-permission","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/insenseanalytics%2Flaravel-nova-permission/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/insenseanalytics%2Flaravel-nova-permission/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/insenseanalytics%2Flaravel-nova-permission/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/insenseanalytics","download_url":"https://codeload.github.com/insenseanalytics/laravel-nova-permission/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/insenseanalytics%2Flaravel-nova-permission/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28301972,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T11:18:18.743Z","status":"ssl_error","status_checked_at":"2026-01-11T11:07:56.842Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["laravel","nova","permissions","spatie"],"created_at":"2026-01-11T12:00:14.619Z","updated_at":"2026-01-11T12:00:16.834Z","avatar_url":"https://github.com/insenseanalytics.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A Laravel Nova tool for the Spatie Permission package\n\n [![License](https://poser.pugx.org/insenseanalytics/laravel-nova-permission/license)](https://packagist.org/packages/insenseanalytics/laravel-nova-permission)\n [![Latest Stable Version](https://poser.pugx.org/insenseanalytics/laravel-nova-permission/v/stable)](https://packagist.org/packages/insenseanalytics/laravel-nova-permission)\n [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/insenseanalytics/laravel-nova-permission/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/insenseanalytics/laravel-nova-permission/?branch=master)\n [![Total Downloads](https://poser.pugx.org/insenseanalytics/laravel-nova-permission/downloads)](https://packagist.org/packages/insenseanalytics/laravel-nova-permission)\n\nThis [Nova](https://nova.laravel.com) tool lets you:\n- manage roles and permissions on the Nova dashboard\n- use permissions based authorization for Nova resources\n\n## Screenshots\n\u003cimg alt=\"screenshot of the backup tool\" src=\"https://insenseanalytics.github.io/public-assets/laravel-nova-permission/nova-permission-screenshot.png\" /\u003e\n\n## Requirements \u0026 Dependencies\nThere are no PHP dependencies except the [Laravel Nova](https://nova.laravel.com) package and the [Spatie Permission](https://github.com/spatie/laravel-permission) package.\n\n## Installation\nYou can install this tool into a Laravel app that uses [Nova](https://nova.laravel.com) via composer:\n\n```bash\ncomposer require insenseanalytics/laravel-nova-permission\n```\n\nNext, if you do not have package discovery enabled, you need to register the provider in the `config/app.php` file.\n```php\n'providers' =\u003e [\n    ...,\n    Insenseanalytics\\LaravelNovaPermission\\NovaPermissionServiceProvider::class,\n]\n```\n\nNext, you must register the tool with Nova. This is typically done in the `tools` method of the `NovaServiceProvider`.\n\n```php\n// in app/Providers/NovaServiceProvider.php\n\npublic function tools()\n{\n    return [\n        // ...\n        \\Insenseanalytics\\LaravelNovaPermission\\LaravelNovaPermission::make(),\n    ];\n}\n```\n\nNext, add `MorphToMany` fields to your `app/Nova/User` resource:\n\n```php\nuse Laravel\\Nova\\Fields\\MorphToMany;\n\npublic function fields(Request $request)\n{\n    return [\n        // ...\n        MorphToMany::make('Roles', 'roles', \\Insenseanalytics\\LaravelNovaPermission\\Role::class),\n        MorphToMany::make('Permissions', 'permissions', \\Insenseanalytics\\LaravelNovaPermission\\Permission::class),\n    ];\n}\n```\n\nFinally, add the `ForgetCachedPermissions` class to your `config/nova.php` middleware like so:\n\n```php\n// in config/nova.php\n'middleware' =\u003e [\n\t'web',\n\tAuthenticate::class,\n\tDispatchServingNovaEvent::class,\n\tBootTools::class,\n\tAuthorize::class,\n\t\\Insenseanalytics\\LaravelNovaPermission\\ForgetCachedPermissions::class,\n],\n```\n\n## Localization\n\nYou can use the artisan command line tool to publish localization files:\n\n```php\nphp artisan vendor:publish --provider=\"Insenseanalytics\\LaravelNovaPermission\\NovaPermissionServiceProvider\"\n```\n\n## Using Custom Role/Permission Resource Classes\n\nIf you want to use custom resource classes you can define them when you register a tool:\n\n```php\n// in app/Providers/NovaServiceProvider.php\n\npublic function tools()\n{\n    return [\n        // ...\n        \\Insenseanalytics\\LaravelNovaPermission\\LaravelNovaPermission::make()\n            -\u003eroleResource(CustomRole::class)\n            -\u003epermissionResource(CustomPermission::class),\n    ];\n}\n```\n\n## Permissions Based Authorization for Nova Resources\nBy 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.\n\nTo do so, you can use the `PermissionsBasedAuthTrait` and define a `permissionsForAbilities` static array property in your Nova resource class like so:\n\n```php\n// in app/Nova/YourNovaResource.php\n\nclass YourNovaResource extends Resource\n{\n    use \\Insenseanalytics\\LaravelNovaPermission\\PermissionsBasedAuthTrait;\n\n    public static $permissionsForAbilities = [\n      'all' =\u003e 'manage products',\n    ];\n}\n```\n\nThe 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:\n\n```php\n    public static $permissionsForAbilities = [\n      'viewAny' =\u003e 'view products',\n      'view' =\u003e 'view products',\n      'create' =\u003e 'create products',\n      'update' =\u003e 'update products',\n      'delete' =\u003e 'delete products',\n      'restore' =\u003e 'restore products',\n      'forceDelete' =\u003e 'forceDelete products',\n      'addAttribute' =\u003e 'add product attributes',\n      'attachAttribute' =\u003e 'attach product attributes',\n      'detachAttribute' =\u003e 'detach product attributes',\n    ];\n```\n\n### Relationships \nTo allow your users to specify a relationship on your model, you will need to add another permission on the Model. \nFor example, if your `Product` belongs to `User`, add the following permission on `app/Nova/User.php`. : \n\n```php\n    public static $permissionsForAbilities = [\n      'addProduct' =\u003e 'add user on products'\n    ];\n```\n\n## Contributing\n\nContributions 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!\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.txt) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finsenseanalytics%2Flaravel-nova-permission","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finsenseanalytics%2Flaravel-nova-permission","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finsenseanalytics%2Flaravel-nova-permission/lists"}