我是Laravel的新手,每次下订单时我都会尝试发送Slack通知。为了测试,我使用了我的Incoming Webhook。现在,当我将webhook更改为客户端slack webhook时。它仍然向老webhook发送通知。 你能帮帮我解决这个问题吗?
这是我的听众
public function handle(OrderConfirmed $event)
{
$admin=User::find(73);
$user=User::find($event->order->user_id);
$order=Order::find($event->order->id);
Notification::send(User::find(73),(new \App\Notifications\PaymentProcessedNot($user,$order)));
}
这是我的PaymentProcessedNot类
class PaymentProcessedNot extends Notification implements ShouldQueue
{
use Queueable;
public $user;
public $order;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct(\App\User $user,\App\Order $order)
{
$this->user=$user;
$this->order=$order;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['slack'];
}
public function toSlack($notifiable){
return (new SlackMessage)
->success()
->content('A new Payment was just processed.')
->attachment(function ($attachment){
$attachment->title('Order : '. $this->order->order_id)
->fields([
'Amount' => ' ₹'. number_format($this->order->amount,2),
'From' => $this->user->name,
'Payment Mode' => strtoupper($this->order->payment_mode)
]);
});
}
}
这是我的User.php
public function routeNotificationForSlack()
{
return 'new_slack_incoming_webhook';
}
答案 0 :(得分:0)
如果您使用.env,则应清除缓存!
只需检查这实际上是网址吧? 返回'new_slack_incoming_webhook';