I am new to laravel. I have been working on a laravel 5 app with different types of users. I need information about which type of user is currently logged in different sections of my views:
Currently, I have been doing something like below on various controller methods and with the user object, I can determine which type of user it is in my view:
In Controller:
public function someMethod(){
$user = Auth::user();
return view('applications.show', compact('user'));
}
In View:
if($user->is_manager)
// do this
else if($user->is_admin)
// do that
Because I need information about the user-type in various views, I have been calling Auth::user()
in several places and I am beginning to think that this is adding some load on the DB. Is it better to store the user-type in a session variable and what kind of data should I be storing in my session?