-
Notifications
You must be signed in to change notification settings - Fork 5
Installation
Ahmed Alaa Hagag edited this page Nov 26, 2017
·
8 revisions
require the package
$ composer require nagy/permissions-handler
in your config/app.php add
'providers' => [
...
PermissionsHandler\PermissionsHandlerServiceProvider::class
],
'aliases' => [
...
'PermissionsHandler' => PermissionsHandler\Facades\PermissionsHandlerFacade::class,
]
You don't need this step in laravel5.5
package:discover
will do the job :)
In your bootstrap/app.php, make sure you've un-commented
$app->withFacades();
Then, register you class alias and check if it already exists (else your tests will break):
if (!class_exists('PermissionsHandlerFacade')) {
class_alias('PermissionsHandler\Facades\PermissionsHandlerFacade::class', 'PermissionsHandler');
}
To register your ServiceProvider, check your bootstrap/app.php:
/*
|--------------------------------------------------------------------------
| Register Service Providers
|--------------------------------------------------------------------------
|
| Here we will register all of the application's service providers which
| are used to bind services into the container. Service providers are
| totally optional, so you are not required to uncomment this line.
|
*/
$app->register(PermissionsHandler\PermissionsHandlerServiceProvider::class);
Publish the package configurations
php artisan vendor:publish --tag=PermissionsHandler
This will generate tables migrations and config/permissionsHandler.php.
Run the new migrations
php artisan migrate
Include UserTrait
trait into your User model
use PermissionsHandler\Traits\UserTrait;
class User extends Model
{
use UserTrait;