我在通知发送电子邮件中遇到问题我无法获取特定数据
当我尝试获取特定的数据时,例如 $this->equipment->id 它不起作用但如果我使用 $this->equipment 它将显示数组数据
在我的控制器中
$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