Define roles and permissions for Laravel users

dev-master 2017-05-18 07:19 UTC

This package is auto-updated.

Last update: 2020-10-08 16:55:29 UTC


Define roles and permissions for Laravel users

Installation and setup

composer require helori/laravel-permission:dev-master

Configure your application:

// config/app.php
'providers' => [

Publish and run the migrations:

php artisan vendor:publish --provider="Helori\LaravelPermission\PermissionServiceProvider" --tag="migrations"
php artisan migrate

In your app/Providers/AuthServiceProvider.php :

use Helori\LaravelPermission\Models\Permission;
class AuthServiceProvider extends ServiceProvider
	public function boot()
		$permissions = Permission::all();
		foreach($permissions as $permission){
		    Gate::define($permission->name, function (User $user) use($permission) {
		        return $user->hasPermission($permission);

Usage example

In your blade template files :

	<div>this is only for allowed users</div>