Hide/show button on user login Hi , how would i go about showing a button in my navbar if user is logged in ? and hidden if not ? i have a Dashboard page but i don't want everybody to see it unless they are logged in?
@if (Auth::check())
// The user is logged in...
@endif
@if (Auth::guest())
// The user is not logged in...
@endif
Something like :
@if (Auth::check())
<your button>
@endif
Edit: beaten too it ;-)
would this go in the Blade ? ?
Here
@if (Auth::user())
<button>I'm logged in</button>
@else
<button>I'm not logged in </button>
@endif
edit: sorry can find backtick on iphone
I have done like this i assume not correct as its not showing ?
<div id="navbar" class="navbar-collapse collapse">
@if (Auth::user())
<ul class="nav navbar-nav navbar-left" style="margin-top:12px;">
<li><span class="label label-danger"><i class="fa fa-exclamation-triangle" style="color:#ffff33" aria-hidden="true"></i> Currently Beta Version 1.0</span></li>
<li><a href="/dashboard">Return to Dashboard</a></li>
</ul>
@endif
@if (Auth::guest())
<ul class="nav navbar-nav navbar-left" style="margin-top:12px;">
<li><span class="label label-danger"><i class="fa fa-exclamation-triangle" style="color:#ffff33" aria-hidden="true"></i> Currently Beta Version 1.0</span></li>
</ul>
@endif
<ul class="nav navbar-nav navbar-right">
<li><a href="/"><i class="fa fa-home" data-toggle="modal" data-target="#Userlogin" aria-hidden="true"></i> Home</a></li>
<li><a href="/about"><i class="fa fa-diamond" data-toggle="modal" data-target="#Userlogin" aria-hidden="true"></i> About Signl</a></li>
</ul>
</div><!--/.nav-collapse -->
try changing
@endif
@if (Auth::guest())
to
@else
see if somethings shows
Apologies fixed ! was looking at wrong blade lol , i have multiple navs
Please sign in or create an account to participate in this conversation.