vendredi 30 septembre 2016

Get relationship from notification

I've set up database notifications for my application.

In my notification class, I've added this:

/**
 * Get the array representation of the notification.
 *
 * @param  mixed  $notifiable
 * @return array
 */
public function toArray($notifiable)
{
    return [
        'post_id' => $this->post->id,
    ];
}

Which references the id of a Post.

What I want to do is display the Post when the user views their notifications. Of course, I have a posts table, but I'm not sure how I would get the post data given the post_id from the notification array.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire