musa11971/laravel-autopolicy

This package is abandoned and no longer maintained. No replacement package was suggested.

Package that automatically loads your Laravel policies for you.

v1.0.0 2019-01-06 21:31 UTC

This package is auto-updated.

Last update: 2022-08-08 17:03:31 UTC


README

Latest Version on Packagist Quality Score Total Downloads

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.