W
W
WildZero2015-08-27 22:32:38
Laravel
WildZero, 2015-08-27 22:32:38

How to arrange routing depending on the user role?

There was a situation that on one url (for example "/home"), for different roles of the user it is necessary to call different methods. How to implement it?
version 5.0.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
D', 2015-08-27
@WildZero

In the normal way - no way.
Make one home method and, depending on the role, call one or another method in it.

V
Vyacheslav Plisko, 2015-08-28
@AmdY

You want the wrong thing, call the same method, and already in it pull the one you need based on the role

public function home() {
    $role = Auth::user()->role;
    $method = 'role' . $role; 
     $this->{$method}();
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question