triotechnology / laravel-permission
Laravel Policy integration with spatie/laravel-permission
Requires
- php: ^8.3
- illuminate/contracts: ^10.0||^11.0
- spatie/laravel-package-tools: ^1.16
- spatie/laravel-permission: ^6.13
Requires (Dev)
- larastan/larastan: ^2.9
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^9.0.0||^8.22.0
- pestphp/pest: ^3.0
- pestphp/pest-plugin-arch: ^3.0
- pestphp/pest-plugin-laravel: ^3.0
- phpstan/extension-installer: ^1.3
- phpstan/phpstan-deprecation-rules: ^1.1
- phpstan/phpstan-phpunit: ^1.3
This package is auto-updated.
Last update: 2025-07-01 00:12:44 UTC
README
This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.
Installation
You can install the package via composer:
composer require triotechnology/laravel-permission
You can publish the config file with:
php artisan vendor:publish --tag="laravel-permission-config"
Usage
Use the provided Triotechnology\Permission\Policies\Policy
class as a base class for your policies.
<?php
namespace App\Policies;
use TrioTechnology\Permission\Policies\Policy as BasePolicy;
class UserPolicy extends BasePolicy {}
Add a Permission enum to your project under the App\Permissions
namespace with the name <Model>Permission
.
The cases of the enum should follow camelCase and the values should follow some consistent pattern e.g. <model>.<action>
.
The base policy follows standard Laravel action names, with some extras added for convenience.
<?php
namespace App\Permissions;
enum UserPermission: string
{
case viewAny = 'users.view_any';
case view = 'users.view';
case create = 'users.create';
case update = 'users.update';
case delete = 'users.delete';
case forceDelete = 'users.force_delete';
// Extra actions
case forceDeleteAny = 'users.force_delete_any';
case restore = 'users.restore';
case reorder = 'users.reorder';
case replicate = 'users.replicate';
}
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- William Bell
License
The MIT License (MIT). Please see License File for more information.