Laravel - Notifications - Formatting Database Notifications

If a notification supports being stored in a database table, you should define a toDatabase or toArray method on the notification class. This method will receive a $notifiable entity and should return a plain PHP array. The returned array will be encoded as JSON and stored in the data column of your notifications table. Let's take a look at an example toArray method:

     * Get the array representation of the notification.
     * @param  mixed  $notifiable
     * @return array
    public function toArray($notifiable)
        return [
            'invoice_id' => $this->invoice->id,
            'amount' => $this->invoice->amount,