D
D
Dmitry2016-07-29 01:34:06
Laravel
Dmitry, 2016-07-29 01:34:06

How to extend Sentinel class in Laravel 5?

There is a project on L5.2 .
It has an authorization based on the cartalyst/sentinel package .
It is necessary to expand the functionality, for example, add a simple method for checking belonging to several roles (in the original there is only the inRole($role) method , it checks only one role).
If I understood everything correctly - you can extend the User model from \Cartalyst\Sentinel\Users\EloquentUser , but it did not work and every time you get a user, the original \Cartalyst\Sentinel\Users\EloquentUser model is returned , and not, for example, App \User (this model is assigned in config/cartalyst.sentinel.php ).
How can you implement the required functionality (roughly speaking, you need a method like inRoles(array $arr) , where $arr is an array like ['admin', 'moderator'] )?
The approach with creating a helper without the Sentinel extension was not considered, because I think that this is not the right solution. If it's not, please correct it.
Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey, 2016-07-29
@rdifb0

Edit the config and change the user class to your own.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question