I'm using a view composer to get data from this table and send it back to my view
class NavComposer
{
public function compose(View $view)
{
if (Auth::check()) {
$view->with('unread_notifications', DB::table('notifications')->where([
['read_at', '=', NULL],
['notifiable_id', '=', Auth::user()->id],
])->get());
}
}
}
My view:
@foreach($unread_notifications as $notification)
{{ $notification->data }}
@endforeach
What I am getting:
{"id":79,"sender":"Diana","receiver":"Alex","subject":"Subject","body":"Lorem ipsum"}
What I want to display:
ID: 79
Subject: Subject
Body: Lorem Ipsum
I apologize in advance if this is very simple stuff I dont know much about JSON