-
Notifications
You must be signed in to change notification settings - Fork 216
Installation
belemlc edited this page Oct 25, 2019
·
24 revisions
composer require kodeine/laravel-acl
If using Laravel 5.x make sure to install version 1.0
composer require kodeine/laravel-acl "^1.0"
Add the package to your application service providers in config/app.php
'providers' => [
...
Kodeine\Acl\AclServiceProvider::class,
],
Publish the package config to your application.
$ php artisan vendor:publish --provider="Kodeine\Acl\AclServiceProvider"
Run migrations.
$ php artisan migrate
Use your own models.
Once you publish, it publishes the configuration file, config/acl.php, where you can define your own models which should extend to Acl models.
return [
'role' => 'Kodeine\Acl\Models\Eloquent\Role',
'permission' => 'Kodeine\Acl\Models\Eloquent\Permission',
];
Add the following to your app/Http/Kernel.php
protected $routeMiddleware = [
....
'acl' => \Kodeine\Acl\Middleware\HasPermission::class,
];
Next, add the HasRole
trait to your User model:
use Kodeine\Acl\Traits\HasRole;
class User extends Model implements AuthenticatableContract, CanResetPasswordContract
{
use Authenticatable, CanResetPassword, HasRole;
}