在他点击确认交付后,我试图在 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)
萧十郎