I have a database with points, and want to subtract the points I just added after a year. I figured I would use a queue job and subtract my points later. I followed this official laravel link: https://laravel.com/docs/4.2/queues#queueing-closures
Here is a snippet:
DB::table('users')->where('id', $user_id)->increment('points_single', $points);
//create the date when the points should be subtracted
$date = Carbon::now()->addMinutes(120);
//push the job onto the queue
Queue::later($date, function($job) use ($user_id, $points)
{
DB::table('users')->where('id', $user_id)->decrement('points_single', $points);
$job->delete();
});
The problem is the job runs instantly, even though I specified a new date time. Why is that?