jeudi 13 octobre 2016

Object getting converted to array?

I'm trying to update a notification's data (for displaying it in a view):

$notifications = $user->notifications()->paginate(15);

foreach ($notifications as $notification)
{
    $post = Post::where('id', $notification->data['post_id'])
        ->first();
    $notification->data = $post;
}

But when I do this in my view:

@foreach ($notifications as $notification)
    
@endforeach

It shows that the data is an array. Why does it convert the Post model object to an array and how can I stop this from happening?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire