jeudi 29 août 2019

Norifications:: not passing the specific data but working with array

i have a problem in Notification send email i cant get the specific data

when i tried to get the data specific like $this->equipment->id its not working but if i used $this->equipment it will display the array data

in my controller

        $equipment = Equipment::where('id','1')->get();
        Notification::send($users, new Equipment($equipment));

in my Notification
``<?php

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;

class Equipment extends Notification
{
    use Queueable;
    public $equipment;

    public function __construct($equipment)
    {
        $this->equipment = $equipment;
    }


    public function via($notifiable)
    {
        return ['mail'];
    }


    public function toMail($notifiable)
    {
        return (new MailMessage)
                    ->line($this->equipment->id.'The introduction to the notification.')
                    ->action('Notification Action', url('/'))
                    ->line('Thank you for using our application!');
    }


    public function toArray($notifiable)
    {
        return [
            //
        ];
    }
}


$this->equipment is working 
but $this->equipment->id is not working



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire