Code

@if(Auth::user()->id_UsGr == 1) <li class="nav-item"> <a class="nav-link" href="/admin">Админка</a> </li> @endif 

Here @if (Auth :: user () -> id_UsGr == 1) checks if the logged-in user id_UsGr = 1 then displays the list.

On a razlogin, it gives an error "Trying to get the property of non-object" when checking the Auth :: user () for a match.

I do not understand what is wrong?

    1 answer 1

    It is difficult to say without clarification on the framework or at least the description of the authorization algorithm, but most likely the situation is this - the user is no longer logged in and therefore Auth::user() returns null , the property id_UsGr which you are trying to get, but this is no longer an object. So the error is decrypted.

    Trying to get property of non-object