1 回答

TA貢獻1848條經驗 獲得超6個贊
當通知請求頻道時mail,Laravel 從特征中調用此代碼Illuminate\Notifications\RoutesNotifications(由特征擴展Illuminate\Notifications\Notifiable)
/**
* Get the notification routing information for the given driver.
*
* @param string $driver
* @param \Illuminate\Notifications\Notification|null $notification
* @return mixed
*/
public function routeNotificationFor($driver, $notification = null)
{
if (method_exists($this, $method = 'routeNotificationFor'.Str::studly($driver))) {
return $this->{$method}($notification);
}
switch ($driver) {
case 'database':
return $this->notifications();
case 'mail':
return $this->email;
}
}
因此,您有兩種解決方法:
您的Driver模型需要有一個email屬性,該屬性將成為郵件到達的路線。
在您的模型中定義一個routeNotificationForMail方法,該方法將以自定義方式計算路線
/**
* @param \Illuminate\Notifications\Notification|null $notification
* @return string
*/
public function routeNotificationForMail($notification)
{
return $this->address;
}
- 1 回答
- 0 關注
- 120 瀏覽
添加回答
舉報