Skip to content

Instantly share code, notes, and snippets.

@antimech
Last active May 28, 2023 06:29
Show Gist options
  • Save antimech/f94b7235d6a099d5f394a7358c987082 to your computer and use it in GitHub Desktop.
Save antimech/f94b7235d6a099d5f394a7358c987082 to your computer and use it in GitHub Desktop.
Laravel, subscription renewal for Telegram Bot Users
<?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