In laravel Blade templating we can exclude some parts of HTML with this code:
@if (Auth::user())
<li><a href="{{ url('/home') }}">Mein Profil</a></li>
<li><a href="{{ url('/admin') }}">Admin</a></li>
@else
<li><a href="{{ url('/home') }}">Mein Profil</a></li>
@endif
If user is authenticated then show home and admin links and if user is not authenticated then show only home link.
My question is how to make a check here if user is admin?
I have default login system from laravel and i just added one more column in table users -> ('admin') with tinyint value 1 and in this video https://www.youtube.com/watch?v=tbNKRr97uVs i found the code for checking if user is admin
if (!Auth::guest() && Auth::user()->admin )
and it works in AdminMiddleware.php but it doesn't work in blade. How to make this working??
echo "<pre>"; print_r(Auth::user()); die()
in your question, So we can see that admin column is coming or not – Flaxseed