if (auth()->check() && (auth()->user()->hasRole('Admin'))) {
$people = Person::latest()->paginate(5);
} else {
$people = Person::where('user_id', $user->id)->latest()->paginate(5);
}
My editor code analysis tool is not able to detect the method.Undefined method 'hasRole'.intelephense(1013)
The 'if' condition is working correctly.
I have used this solution from GitHub:
/** @var \App\Models\User */;$uservariable as a result ofauth()->user()orAuth::user();$user->hasRole()in your code.