<?php
namespace App\Jobs;
use App\User;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Support\Facades\Log;
class SendReminderEmail implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $user;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct(User $user)
{
$this->user = $user;
//
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
//
Log::info(",", ["id" => $this->user->id, "name" => $this->user->name]);
}
public function fail($exception = null)
{
}
}
I set the trigger queue in the controller when the request comes. It seems to me that delay should be delayed, and then I set it to execute in 30 seconds, so when I request to play, I immediately check the log and the data is output to laravel.log, instead of 30 seconds later. Database queue used