文档[消息通知]部分toArray($notifiable)里的代码不理解$this->invoice来源
文档目录:laravelacademy.org/post/22007#toc-...
格式化数据库通知
/**
* 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,
];
}
问题: $this->invoice 是模型吧,里面定义的是什么样子?要对应表么?
invoice
应该是构造器传入的模型, 这无关紧要, 只要返回一个自定义数组即可, 这个数组会保存到表中的data
字段,说白了就是消息的数据载体. 消费队列时会读取data