Reputation: 3422
When I'm on a exception page (for example: abort(404);
) I can't access the user data.
Normal page (index.blade.php
)
Exception or abort page
I want the User
model also on the exception pages, but how do I do it?
For example:
@if(Auth::check())
{{ Auth::user()->name }}
@else
Not logged in
@endif
Upvotes: 0
Views: 142
Reputation: 1928
Open Kernel.php
in app/Http/Kernel.php
Move this Classes from $middlewareGroups
to $middleware
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
So you'll have something like
protected $middleware = [
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
];
Upvotes: 1