B
B
BonBon Slick2017-04-22 19:54:55
Laravel
BonBon Slick, 2017-04-22 19:54:55

Larave 4.2 doesn't see Auth::user() on the front end?

You need to get the current user for operations with him, what content to display, however:

{{ dd(Auth::user())  }}
// NULL

Strange, because if you post a comment:
if(Auth::guest()){
      $user_id = 0;
    } else {
      $user_id = Auth::User()->id;
    }

This is the place where the comment is saved, it already sees the current user.
Tried adding middleware:
Route::group(array('before' => 'web'), function() {
.....
Route::post('comments/store','[email protected]');
});

Dumped Auth::guest() says that the guest, but if I put a comment writes as from the admin. It somehow crookedly sees the admin as a guest on the front, and as an admin on the back-end, while saving the comment.
Why can't he see at the front?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
javanub, 2017-04-23
@javanub

dd($user_id) returns what?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question