musa11971 / laravel-autopolicy
Package that automatically loads your Laravel policies for you.
Requires
- php: ^7.1.3
- ext-curl: *
- ext-json: *
This package is auto-updated.
Last update: 2022-08-08 17:03:31 UTC
README
The musa11971/laravel-autopolicy
package will automatically register your Laravel policies, instead of having you manually register them.
Once the policies are "autoloaded", the package will cache the policy map to maintain application performance.
Installation
You can install the package via composer:
composer require musa11971/laravel-autopolicy
Usage
The package will automatically enable itself once you have installed it via composer. There are no configuration options.
You no longer need to register your policies manually in the AuthServiceProvider
. All you need to do, is make sure every policy class has the following constant:
const MODEL = User::class;
This is required so that the package knows which model should be assigned to this policy.
Example:
<?php namespace App\Policies; use App\User; use Illuminate\Auth\Access\HandlesAuthorization; class UserPolicy { use HandlesAuthorization; const MODEL = User::class; // Policy functions go here... }
Credits
License
The MIT License (MIT). Please see License File for more information.