the inquisitor
the inquisitor

Reputation: 109

executing an event after a long time period laravel

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

Answers (2)

user320487
user320487

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

jiGL
jiGL

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

Related Questions