Junges Laravel ACL


April 25th, 2019


Junges Laravel ACL is a package by Mateus Junges that helps you to associate users with permissions and permission groups.

This package stores permissions for users and groups (to which users may belong) in the database with the following core features:

  • Check a user for ACL permissions
  • Sync a user’s permissions
  • Sync a group’s permissions
  • Check permissions in the view layer with @can or provided custom directives

At the heart of this package is the UserTrait:

1use Illuminate\Foundation\Auth\User as Authenticatable;
2use Junges\ACL\Traits\UsersTrait;
4class User extends Authenticatable
6 use UserTrait;
8 //

You can sync user and group permissions with the syncPermissions() method:

1// With permission id array:
2$user->syncPermissions([1, 2, 4]);
4// With permission slugs array:
5$user->syncPermissions(['permission-slug-1', 'permission-slug-2']);
7// With instance of permission model arrays:
8$user->syncPermissions([Permission::find(1), Permission::find(2)]);
10// Just as above you can sync group permissions. Here's the id version:
11$group->syncPermissions([1, 2, 4]);

Check out the usage documentation for a complete list of methods and package capabilities. You can learn more about this package and check out the source code on GitHub at mateusjunges/laravel-acl.

Filed in:

Paul Redmond

Full stack web developer. Author of Lumen Programming Guide and Docker for PHP Developers.