I need you to guide me as to the best way to control various types of users, I currently have 3 (Admin, user, editor), the role field I have in the users table as an integer (0,1,2), they can increase the number of roles. What is the best or most common way to do it?
I've seen this info in several places
Controller
private function isAdmin(){
if (Auth::user()->user == 1) return true;
else return false;
}
public function admin(){
if ($this->isAdmin()){
return View('admin.admin');
} else{
return redirect()->back();
}
}
Route:
Route::get('admin', 'AdminController@admin');
View
@if (Auth::check())
@if (Auth::user()->user == 1)
<li><a href="{{url('admin')}}">Panel de Administrador</a></li>
@endif
<li><a href="{{url('user')}}">{{Auth::user()->name}}</a></li>
<li><a href="{{url('auth/logout')}}">Salir</a></li>
@else
<li><a href="{{url('auth/login')}}">Iniciar sesión</a></li>
@endif
But this is only for the administrator, how could I adapt it for more roles ?, what other way is it right to do it?