Skip to content
Matt edited this page May 1, 2015 · 24 revisions

Installation

Composer

Add this to your composer.json file, in the require object:

"kodeine/laravel-acl" : "dev-master"

After that, run 'composer update' to install the package.

Configuration

Register Service Provider

Add the package to your application service providers in config/app.php

'providers' => [
    ...
    'Kodeine\Acl\AclServiceProvider',
],

Publish the package migrations 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 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',
];

Middleware Setup

Add the following to your app/Http/Kernel.php

protected $routeMiddleware = [
    ....
    'acl' => 'Kodeine\Acl\Middleware\HasPermission',
];

Model Setup

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;
}