Changeset View
Changeset View
Standalone View
Standalone View
src/app/Console/Commands/Wallet/ChargeCommand.php
- This file was moved from src/app/Console/Commands/WalletCharge.php.
<?php | <?php | ||||
namespace App\Console\Commands; | namespace App\Console\Commands\Wallet; | ||||
use App\Console\Command; | use App\Console\Command; | ||||
use App\Wallet; | |||||
class WalletCharge extends Command | class ChargeCommand extends Command | ||||
{ | { | ||||
/** | /** | ||||
* The name and signature of the console command. | * The name and signature of the console command. | ||||
* | * | ||||
* @var string | * @var string | ||||
*/ | */ | ||||
protected $signature = 'wallet:charge {wallet?}'; | protected $signature = 'wallet:charge {wallet?}'; | ||||
Show All 10 Lines | class ChargeCommand extends Command | ||||
* @return mixed | * @return mixed | ||||
*/ | */ | ||||
public function handle() | public function handle() | ||||
{ | { | ||||
if ($wallet = $this->argument('wallet')) { | if ($wallet = $this->argument('wallet')) { | ||||
// Find specified wallet by ID | // Find specified wallet by ID | ||||
$wallet = $this->getWallet($wallet); | $wallet = $this->getWallet($wallet); | ||||
if (!$wallet || !$wallet->owner) { | if (!$wallet) { | ||||
$this->error("Wallet not found."); | |||||
return 1; | |||||
} | |||||
if (!$wallet->owner) { | |||||
$this->error("Wallet's owner is deleted."); | |||||
return 1; | return 1; | ||||
} | } | ||||
$wallets = [$wallet]; | $wallets = [$wallet]; | ||||
} else { | } else { | ||||
// Get all wallets, excluding deleted accounts | // Get all wallets, excluding deleted accounts | ||||
$wallets = Wallet::select('wallets.*') | $wallets = \App\Wallet::select('wallets.*') | ||||
->join('users', 'users.id', '=', 'wallets.user_id') | ->join('users', 'users.id', '=', 'wallets.user_id') | ||||
->withEnvTenantContext('users') | ->withEnvTenantContext('users') | ||||
->whereNull('users.deleted_at') | ->whereNull('users.deleted_at') | ||||
->cursor(); | ->cursor(); | ||||
} | } | ||||
foreach ($wallets as $wallet) { | foreach ($wallets as $wallet) { | ||||
$charge = $wallet->chargeEntitlements(); | $charge = $wallet->chargeEntitlements(); | ||||
Show All 17 Lines |