hjortur17
5 months ago

Trying to get property 'username' of non-object

Posted 5 months ago by hjortur17

Hi, I'm trying to make a path to profile but I'm getting an error message. Trying to get property 'username' of non-object

Here is where I'm trying to use the auth username:

<a href="{{ route('profile', auth()->user()->username) }}"><img src="/css/img/test_avatar.jpg" class="w-10 h-10 border border-grey-light rounded-full mx-auto"></a>

Here is the web.php

Route::get('/notendur/{user}', '[email protected]')->name('profile');

And here is the ProfileController

public function show(User $user)
    {
        return view('profiles.show', [
            'profileUser' => $user,
            'replies' => $user->replies()->paginate(30)
        ]);
    }

Please sign in or create an account to participate in this conversation.