L
L
lzy2020-08-21 13:33:40
Yii
lzy, 2020-08-21 13:33:40

How to check in the database in the background?

Good afternoon, on the site I am doing the Subscription function, that is, the account is given 1 month of free use. Where, in what place of the project you need to register a trigger or a function that will always compare data and turn off those that have expired (Now this is done only after a person logs into the account)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dmitry Kim, 2020-08-21
@lzy

Add a field to the user where to store the last subscription date.

class User {
    public function isSubscriptionWorks() {
        return $this->subscibed_at > strtotime('1 month ago');
    }
}

T
The3fon, 2020-08-21
@The3fon

The simplest solution is to run tasks with cron.

F
FanatPHP, 2020-08-21
@FanatPHP

If it is still not clear, then no triggers are needed .
A "deactivated account" is one whose subscription has expired.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question