Add this piece of code to the User model.
public function hasAnyRole($roles)
{
return in_array($this->getRoleNames()[0] ?? '', $roles);
}
Then you can call it.
if (auth()->user()->hasAnyRole(['user'])) {
//
}
But I recommend to you use this package
https://spatie.be/docs/laravel-permission/v4/introduction
WIth that package you can do
https://spatie.be/docs/laravel-permission/v4/basic-usage/role-permissions#checking-roles