khushboom
khushboom

Reputation: 95

run a piece of code after 30 min after the entry in db, in laravel

I am working on Laravel as a back-end for mobile app.

As the app make the entry in db, then after 30 minutes I have to send push notification to the app indicating that you have used the app for 30 minutes.

Does queue and cron will solve my problem? Or is there any other way to do this? I am new to Laravel. please give me some suggestions.

Upvotes: 0

Views: 980

Answers (1)

ata
ata

Reputation: 1354

The queue is enough for this task. You should use delayed dispatching. When users use an api endpoint or create some entity you dispatch delaying 30 minutes. Something like this:

SendNotification::dispatch($podcast)->delay(now()->addMinutes(30));

Upvotes: 2

Related Questions