我正在尝试为我定义的每个事件设置webhook网址。
所以我有类似下面的内容。
的usermodel
<?php
namespace app\Model\User;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use App\Model\Device as DeviceModel;
/**
* Class User
* @package app\Model\User
*/
class User extends Authenticatable
{
use Notifiable;
/**
* @var string
*/
public $slackChannel;
/**
* Route notifications for the Nexmo channel.
*
* @return string
*/
public function routeNotificationForSlack() : string
{
if ( $this->slackChannel ){
return config('slack.channels.'.$this->slackChannel);
}
}
/**
* @param string $slackChannel
* @return object
*/
public function slackChannel(string $slackChannel) : object
{
$this->slackChannel = $slackChannel;
return $this;
}
}
作业的
public function handle()
{
foreach( $this->users as $user ) {
$recipient = $user;
$user->slackChannel('order-requested')->notify(new OrderSubmittedByClient($this->order, $recipient));
}
}
配置/松弛
return [
'channels' => [
'order-requested' => 'https://hooks.slack.com/services/xxxxxx',
]
];
即使我将$this->slackChannel
设置为某个字符串,但当涉及routeNotificationForSlack
时,它会返回null
。
我做错了什么?我怀疑中间件中有jwt
,但这有关系吗?