File size: 802 Bytes
5f32fbd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | <?php
namespace App\Console\Commands;
use App\Models\YokassaSubscriptions;
use App\Services\GatewaySelector;
use Illuminate\Console\Command;
class CheckYookassaCommand extends Command
{
protected $signature = 'app:check-yookassa-command';
protected $description = 'Command description';
public function handle(): void
{
$items = YokassaSubscriptions::query()
->where('subscription_status', 'active')
->orWhere('subscription_status', 'yokassa_approved')
->get();
foreach ($items as $activeSub) {
$data_end_sub = $activeSub->next_pay_at;
if (now()->gt($data_end_sub)) {
$result = GatewaySelector::selectGateway('yokassa')::handleSubscribePay($activeSub->id);
}
}
}
}
|