This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.

Define roles and permissions for Laravel users

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

This package is auto-updated.

Last update: 2021-10-08 19:11:13 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>