instead of Auth::guard('guard')->guest() use
@if(!Auth::check())
and your question little bit confusing explain in detail
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I use Auth::guard('guard')->guest() in the layout of my page to determine whether or not to show the "Login" and "Register" buttons or not - this 'guard' is the guard I have created for a second type of user my system uses. When I'm on a page which uses a controller that utilises the "auth" middleware with parameters "web,guard" then the page loads correctly, but when I visit a page which uses a controller that utilises the "guest" middleware with no parameters then the page doesn't load correctly and gives the error "Trying to get property of non-object". When I (on the same page) have the result of guest() and the result's type printed I get that it is a true boolean (as expected). When I print the type of Auth::guard('guard'), I get that it is an object. I'd appreciate any help understanding this.
Please or to participate in this conversation.