Last active
May 28, 2023 06:29
-
-
Save antimech/f94b7235d6a099d5f394a7358c987082 to your computer and use it in GitHub Desktop.
Laravel, subscription renewal for Telegram Bot Users
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (!auth()->user()) { | |
return abort(401); | |
} | |
$users = \App\TelegramBotUser::subscribers(); | |
echo $users->count(); | |
echo '<br>'; | |
foreach ($users as $user) { | |
$last_payment = $user->payments->last(); | |
$paid_until = new Carbon($user->expired_at); | |
$paid_until->addWeek(); | |
// mannually check the users list first then uncomment it and run it again | |
/*$user->update([ | |
'expired_at' => $paid_until | |
]); | |
$last_payment->update([ | |
'paid_until' => $paid_until | |
]);*/ | |
echo $user->id; | |
echo ' '; | |
echo $user->expired_at; | |
echo ' '; | |
echo $last_payment->paid_until; | |
echo '<br>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment