Display current user in header

This commit is contained in:
bad 2021-11-26 11:23:50 +01:00
parent adf94ac2a1
commit f736882f5e
3 changed files with 7 additions and 4 deletions

View file

@ -12,7 +12,12 @@
<nav> <nav>
<i class="fa fa-hamburger"></i> <i class="fa fa-hamburger"></i>
<div> <div>
<a href="{{ route("login") }}">Login</a> @auth
<a href="{{ url("user") }}"> Hello {{ Auth::user()->name }} </a>
@endauth
@guest
<a href="{{ route("login") }}">Login</a>
@endguest
</div> </div>
</nav> </nav>
<main> <main>

View file

@ -31,6 +31,4 @@
</form> </form>
</div> </div>
</div> </div>
</body>
</html>
@endsection() @endsection()

View file

@ -25,7 +25,7 @@ Route::get('/', [MainPageController::class, "index"])->name("main");
Route::get('/user', function () { Route::get('/user', function () {
$user = Auth::user(); $user = Auth::user();
return view("user", ["user"=>$user]); return view("user", ["user"=>$user]);
})->middleware("auth"); })->middleware("auth")->name("user");
Route::view("/login", "login"); Route::view("/login", "login");