1

I'm using Laravel but I searched for the appropriate way to do ..

We write articles in our website and give them a publishing date.

Those articles won't display in our website before the publishing date.

Is there any way by using Laravel or another way, to do something immediately after the publishing is done, ex. sending an email

user9500574
  • 142
  • 1
  • 11

1 Answers1

4

You can send a job to your queue and delay it until the post is published.

https://laravel.com/docs/5.7/queues#delayed-dispatching



Edited example from documentation:

ProcessPodcast::dispatch($podcast)->delay($article->published_at);
Jerodev
  • 32,252
  • 11
  • 87
  • 108
  • Thanks, Can the delay wait for weeks, or just few hours? at all, I opened the laravel queues page to learn more – user9500574 Nov 15 '18 at 16:28
  • 1
    It can wait for as long as you want. The delay sets a timestamp when the job should be executed. – Jerodev Nov 15 '18 at 20:36