Users Usage

View Users

The usage is easy, inside the panel, you will see a Users List button, click it, and then you'll be seeing a list of all users. Here you can navigate to manage users and users roles, or well delete these.

Authorize Users

To determine if user has a permission or a role, you need the functions hasPermission() or hasRole(), and you have two options to use it, the first one, is using the model Laralum\Users\Models\User, and the second one is by importing the trait Laralum\Roles\Traits\HasRolesAndPermissions.

Using Models

This method it's okay but may be very large and uncomfortable to use it. The way to use it is like following code:

if (\Laralum\Users\Models\User::findOrFail(Auth::id())->hasPermission('permission.slug')) {
    // User has permission 'permission.slug'
} else {
    // User has not permission 'permission.slug'
}

Using Traits

The recommended way to Authorize users is by using trait Laralum\Roles\Traits\HasRolesAndPermissions on the App\User model.

Simply import class as following code line:

use Laralum\Roles\Traits\HasRolesAndPermissions as LaralumAuthorization;

and the use it inside class User:

use LaralumAuthorization;

Then you can authorize users as following code

if (Auth::User()->hasPermission('permission.slug')) {
    // User has permission 'permission.slug'
} else {
    // User has not permission 'permission.slug'
}

Did you know?

Laralum is found to be the only CMS that still gives you the ability to manage the views and the website the way you like, without any problems with the correct functionality of it.


Donations

Please consider donating if you liked the project, we currently have no funding and we're spending a lot of time maintaining and developing this project.


The creators

Èrik Campobadal Forés

Aitor Riba Archilla


Major Contributors

Krishan König

Laraketai

Snow McFox