2 years ago

#62103

test-img

firemankurt

Can a Queue be rescheduled in OctoberCMS

Task:

I am creating a way that a frontend user can send a message and schedule a time for it to be delivered. To accomplish this, I am storing the message info in database tables and then Setting a queue to fire a send function at the appropriate time.

Question:

If the user changes their mind about the time to send the message after this code is executed, is there a way to remove this from the queue and then re add it to fire at a different time?

Example

$data = ['message_id' => $this->messageModel->id];
$queue = Queue::later($this->send_at, 'KurtJensen\Twilio\Classes\SendQueue', $data);

// ==== Everything works great up to this point =======

// Don't know if this will work
// Can I get a queue identifier here?

$this->messageModel->queue_id = $queue->id;
$this->messageModel->save();

Then later to change time:

$this->messageModel= Message::find($id);
$q_id = $this->messageModel->queue_id;

// ==== I doubt this would work or if canceling a queue is possible ======= 
Queue::cancel($q_id);

$queue = Queue::later($new_time, 'KurtJensen\Twilio\Classes\SendQueue', $data);

$this->messageModel->queue_id = $queue->id;
$this->messageModel->save();

php

laravel

queue

octobercms

0 Answers

Your Answer

Accepted video resources