<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Yajny\EventsYj\Library\PayMob\EWalletPayout;
use Yajny\Member\Models\UserPayouts;

class UpdatePayMobEWalletTransactions extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'paymob:e_wallet_update';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Update PayMob EWallet transactions';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $transactionIDs = UserPayouts::where('method_code', 'e-wallet')->where('status', 'processing')->whereNotNull('payment_ref_num')->pluck('payment_ref_num');
        if ($transactionIDs->isNotEmpty()) {
            $EWalletPayout = new EWalletPayout();
            $EWalletPayout->inquire($transactionIDs);
        }
    }
}
