Reputation: 235
Is it possible to Fire Event or listener after certain time in Laravel, my idea is to have one listener for sending mails after one minute, after user registration, cron isnt solution for this case.
Upvotes: 5
Views: 10311
Reputation: 106
In this case a job would be a better options. To be honest queued jobs when firing logic within your application is more suited for this kind of logic.
Jobs require less set up to events as you only need a single class, rather than events and listeners.
To delay your job use the following syntax, where SendReminderEmail is your job. The parameter in the delay function is the number of seconds you wish to delay the process.
$job = (new SendReminderEmail($user))->delay(60);
https://laravel.com/docs/5.1/queues#delayed-jobs
Upvotes: 6