[英]How to solve Call to a member function notify() on array? (laravel 5.3)
我的聽眾是這樣的:
<?php
namespace App\Listeners;
use App\Events\CheckoutOrderEvent;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Mail;
class CheckoutOrderListener
{
public function __construct()
{
//
}
public function handle(CheckoutOrderEvent $event)
{
// dd($event);
$event->data->notify(New \App\Notifications\CheckoutOrder($event->data));
}
}
如果我運行 dd($event),結果是這樣的:
執行時,存在錯誤:調用數組上的成員函數notify()
如何解決?
您需要在具有Illuminate\\Notifications\\Notifiable
特征的模型上使用notify()
,但絕對不能在數組上使用。
例如,您可以先獲取一個User
的實例:
$user = User::where('email', $event->data['email'])->first();
然后使用notify()
:
$user->notify(....)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.