I'm completely new to Laravel, MVC and templating engines in general.
I need to show certain navbar buttons and options if a user is logged in such as: Notifications, Logout, Profile, etc... and a Login button otherwise.
Any help on how I could address this the right way is greatly appreciated. This is what I'm considering at the moment:
User
object is always passed to the view.User
is set (meaning it's logged in) to include the appropriate partial blade template for the navbar.app.blade.php:
...
@if (isset($user))
@include('partials.navbarlogged')
@else
@include('partials.navbar')
...
Is this the best method? Thanks for your time!
If you are using Laravel 5's built in User model you can simply do
@if (Auth::check())
//show logged in navbar
@else
//show logged out navbar
@endif