webfuelcode
2 months ago
438
8
Laravel

Undefined index: user

Posted 2 months ago by webfuelcode

Undefined index: user (View: C:\xampp\htdocs\machine\resources\views\profile\notifications.blade.php)

Why do I see the undefined index error?

Controller:

public function show()
{
return view('profile.notifications', ['notifications' => auth()->user()->notifications]);
}

View:

<li>
            @foreach ($notifications as $notification)
                {{ $notification->data['user']['name'] }}
                commented on
                {{ $notification->data['thread']['subject'] }}
                 - {{ $notification->data['user']['created_at'] }}<br>
            @endforeach
</li>

Screenshot is here. Image link is here: "https://i.ibb.co/9rK5xbg/lara-notice.png

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