vendredi 7 février 2020

Weird bug when passing data to Laravel notification constructor

I have a variable, called $applicants and it contains data from users table and other tables from eager load.

Something like this:

enter image description here

Then I pass that variable to a Laravel Notification class via __construct method. The problem is if I dd the $applicant in the __construct method, the data is preserved, but if I dd it in the toMail method, it only contains data from user table.

enter image description here

Here is the code:

class DailyReportWasGenerated extends Notification implements ShouldQueue {

    use Queueable;

    private $applicants;

    /**
     * Create a new notification instance.
     *
     * @param $applicants
     */
    public function __construct($applicants)
    {
        $this->applicants = $applicants;

        dd($this->applicants->toArray());
    }

    public function toMail($notifiable)
    {
        dd($this->applicants->toArray());
    }



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/385BjKm
via IFTTT

Aucun commentaire:

Enregistrer un commentaire