亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在 30 分鐘后向客戶發送通知?

如何在 30 分鐘后向客戶發送通知?

PHP
慕無忌1623718 2022-10-14 16:31:44
在他點擊確認交付后,我試圖在 30 分鐘后向客戶應用發送通知。我創建了一個事件偵聽器來發送該通知,但是如何讓偵聽器偵聽一個事件并在 30 分鐘后發送該通知?這是我在 APIController 中的確認交付功能:public function confirm_delivery(Request $request){    $id = (int)$request->order_id;    $order = Order::find($id);    Order::where('user_id', $user->id)->find($id)->update(['stage' => 9]);    $type = 'CUSTOMER_';    $uuid = $user->uniqid;    $order_id =$id;    $order_no =$order->order_no;    //Todo::Event to send notfifiction for user to rate place after 30 mins    event(new CustomerRatePlaceEvent($type,$uuid,$order_id,$order_no));    return ResponseHelper::customizedResponse(true, 1, 'Order delivered to customer.');}_在 CustomerRatePlaceEvent 中構造:public $type;public $uuid;public $order_id;public $order_no;public function __construct($type,$uuid,$order_id,$order_no){    $this->type = $type;    $this->uuid = $uuid;    $this->order_id = $order_id;    $this->order_no = $order_no;}事件服務提供者: CustomerRatePlaceEvent::class => [     CustomerRatePlaceListener::class, ],CustomerRatePlaceListener:public function handle($event){    NotificationHelper::?ratePlaceNotification($event->type,$event->uuid,$event->order_id,$event->order_no);}(通知代碼在一個輔助函數中,它工作正常:NotificationHelper::?ratePlaceNotification)
查看完整描述

1 回答

?
蕭十郎

TA貢獻1815條經驗 獲得超13個贊

隊列足以完成此任務。

您應該使用延遲調度 - https://laravel.com/docs/7.x/queues#delayed-dispatching

當用戶使用 api 端點或創建某些實體時,您調度延遲 30 分鐘。

像這樣的東西:

SendNotification::dispatch($podcast)->delay(now()->addMinutes(30));


查看完整回答
反對 回復 2022-10-14
  • 1 回答
  • 0 關注
  • 121 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號