A lightweight Laravel package for reusable, trait-based policy checks supporting CRUD, ownership, and private resource access.
curly-deni/laravel-permission-policy is a Laravel package for a lightweight laravel package for reusable, trait-based policy checks supporting crud, ownership, and private resource access..
It currently has 0 GitHub stars and 183 downloads on Packagist (latest version v1.2.2).
Install it with composer require curly-deni/laravel-permission-policy.
Discover more Laravel packages by curly-deni
or browse all Laravel packages to compare alternatives.
Last updated
A simple and flexible way to define and apply CRUD policies in Laravel using traits.
Designed to work seamlessly with laravel-permission-maker π―
Install the package via Composer:
composer require curly-deni/laravel-permission-policy
After publishing the config file with:
php artisan vendor:publish --tag="permission-policy-config"
Youβll get the following settings in config/permission-policy.php:
return [
'register_gate' => true, // Automatically register default gate with policy bindings
// Toggle specific permission checks:
'read_check' => false, // Use 'read' instead of 'view'
'view_check' => true, // Check for 'view' permission
'create_check' => true, // Check for 'create' permission
'update_check' => true, // Check for 'update' permission
'delete_check' => true, // Check for 'delete' permission
];
π οΈ Note: If you disable the automatic
gateregistration ('register_gate' => false), make sure your custom gate implementation supports passing policy arguments via query parameters. You can use the included helper functions to handle this:
encodeClassWithParams(string $class, array $params): string> Encodes a class name and arguments into a query-safe string.
decodeClassWithParams(string $encoded): array> Decodes the encoded string back into the original class name and parameters.
This package is intended to be used with laravel-permission-maker.
Choose the trait that suits your needs:
| Trait | Description |
| --------------------------------------------------------------------------------- | ------------------------------------- |
| HasResourcePolicy | Basic CRUD permission checks |
| HasPrivateResourcePolicy | Adds private resource view checks |
| HasOwnResourcePolicy | Enables edit/delete for own resources |
| HasOwnAndPrivateResourcePolicy | Combines ownership and private access |
See CONTRIBUTING.md for contribution guidelines.
This package is open-sourced software licensed under the MIT license.