I am using Laravel queued jobs to simply create a copy of my tables in JSON format and delete the created file afterwards. Here is my handle method:
public function handle()
{
unlink($this->file);
}
The code works fine as long as I dispatch the file right after response:
DeleteCreatedFiles::dispatchAfterResponse(/* File path */);
However I want to keep the file for some time before deleting so I used this code:
DeleteCreatedFiles::dispatch(/* file path */)
->delay(now()->addSeconds(30));
The trouble is that the job is never executed no matter how much I wait. I tried using the telescope and keeps showing the pending status. Please help me figure out why this is happening. Thanks!