I was saved my notification into database like this:
public function toDatabase($notifiable)
{
return [
'from' => $this->message->name,
'name'=> $this->message->email,
'subject' => $this->message->subject,
'body' => $this->message->body
];
}
it work fine. Now i want to extract that data into my view, so i do like this:
@foreach ( Auth::user()->unreadNotifications as $notification)
<li><!-- start message -->
<a href="#">
<!-- Message title and timestamp -->
<h4>
{{ $notification->name }}
<small><i class="fa fa-clock-o"></i> 5 mins</small>
</h4>
<!-- The message -->
<p>{{ $notification->subject }}</p>
</a>
</li>
@endforeach
but it give me nothing. so am i do it wrongly?
Noted from the comments The Notification object has a data attribute where all your data is stored so to access it:
change:
{{ $notification->name }}
to
{{ $notification->data['name'] }}
and do this for all your data.