Reputation: 109
I want to have a subscription mechanism in my app, in a way that after 12 months of subscribing an event would occur that changes their status to unsubscribed, how do I create such a listener for a long time period in laravel?
Upvotes: 1
Views: 439
Reputation:
Laravel's task scheduling can handle this.
https://laravel.com/docs/5.5/scheduling
You would be interested in the ->yearly()
method. Add scheduling entries to the App\Console\Kernel
class.
Example:
$schedule->call(function () {
// check subscriptions
})->yearly();
Upvotes: 2
Reputation: 175
First I would save the timestamp in db and second create a cronjob (there is a laravel equivalent) which selects all subscriptions where the timestamp ist older then 12 month.
Upvotes: 0