Skip to main content
Back to packages
2,277 GitHub stars

santigarcor/laratrust

View on GitHub

Description

Laravel role-based access control package

Laratrust is a package that lets you add roles and permissions inside your Laravel application. All of this through a very simple configuration process and API.

Here you can see some examples:

$adminRole = Role::where('name', 'admin')->first();
$editUserPermission = Permission::where('name', 'edit-user')->first();
$user = User::find(1);
 
$user->addRole($adminRole);
// Or
$user->addRole('admin');
 
$user->givePermission($editUserPermission);
// Or
$user->givePermission('edit-user');

You can also check if a user has some permissions or roles:

$user->isAbleTo('edit-user');
$user->hasPermission('edit-user');
 
$user->hasRole('admin');

It also supports teams, multiple users and it has a simple admin panel and it is compatible with Laravel's policies and gates system.

Recent Courses on Laravel Daily

Testing in Laravel 13 For Beginners

26 lessons
1 h 41 min read

Queues in Laravel 13

18 lessons
1 h 12 min read

How to Build Laravel 13 API From Scratch

30 lessons
1 h 23 min

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.