In my system, there are two different dashboards. One for admin and another one for user. In my database there is a column name usertype and there are two int values. 1 is for the admin and 0 is for the users. In my laravel project if the login user trying to access their dashboard then firstly in controller file it will check if he/she is admin or not. If his/her assigned usertype value is 1 then he/she will redirect to the admin dashboard, if it is not 1 then he/she will redirect to the user dashboard. But I got an error
Attempt to read property
usertypeonnull".
The admincontroller code for dashboard redirection are given below
public function admindashboard(){
if(Auth::user()->usertype == 1 ){
return view('admin/pages/admindashboard');
}
else{
return view('viewer.pages.userpanel.userdashboard');
}
}