Reputation:
I have developed a package for Laravel in which I'm trying to fetch the logged in user name but it is giving error. package is currently in the vendor folder
error
ErrorException (E_ERROR)
Trying to get property 'name' of non-object
How I can get current logged in user name?
Upvotes: 3
Views: 1107
Reputation: 1266
You can use
{{auth()->user()->name}}
instead of what you are using currently.
Upvotes: 0
Reputation: 737
Please try to add web middleware in your route like this
Route::group(['middleware' => ['web']], function () {
Route::group(['prefix' => 'admin', 'middleware' => 'auth'], function () {
Route::get('/', ['uses'=>'Admin@index']);
});
});
Upvotes: 3