samedi 7 janvier 2017

How to display JSON Array in Blade view?

My db table structure

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)

@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



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2i1VEW4
via IFTTT

Aucun commentaire:

Enregistrer un commentaire