简体   繁体   中英

executing an event after a long time period laravel

我想在我的应用程序中使用一种订阅机制,这种方式是在订阅事件12个月后会发生,将其状态更改为未订阅,那么如何在laravel中长时间创建这样的侦听器?

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();

首先,我将时间戳保存在db中,其次创建一个cronjob(有一个laravel等效项),它选择时间戳超过12个月的所有订阅。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM