Hiding redudant link in Laravel 8
You can conditionally load HTML in blade based on login with the code below. The function Auth::check
returns true if the user is authenticated.
@if(Auth::check())
// only show this if someone is logged in.
@endif
Route::has
checks if the route exists, not if it's accessible to the user.
Instead, you should use Blade's @auth
and @guest
directives to show different things for logged-in or logged-out users.
https://laravel.com/docs/8.x/blade#authentication-directives
@auth
// The user is authenticated...
@endauth
@guest
// The user is not authenticated...
@endguest