Changeset View
Changeset View
Standalone View
Standalone View
src/app/Console/Commands/Wallet/Charge.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\Wallet; | use App\Wallet; | ||||
use Illuminate\Console\Command; | |||||
class WalletCharge extends Command | class Charge 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?}'; | ||||
/** | /** | ||||
* The console command description. | * The console command description. | ||||
* | * | ||||
* @var string | * @var string | ||||
*/ | */ | ||||
protected $description = 'Charge wallets'; | protected $description = 'Charge wallets'; | ||||
/** | /** | ||||
* Create a new command instance. | |||||
* | |||||
* @return void | |||||
*/ | |||||
public function __construct() | |||||
{ | |||||
parent::__construct(); | |||||
} | |||||
/** | |||||
* Execute the console command. | * Execute the console 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 = Wallet::find($wallet); | $wallet = Wallet::find($wallet); | ||||
if (!$wallet || !$wallet->owner) { | if (!$wallet || !$wallet->owner) { | ||||
$this->error("Wallet not found (or account 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 = Wallet::select('wallets.*') | ||||
->join('users', 'users.id', '=', 'wallets.user_id') | ->join('users', 'users.id', '=', 'wallets.user_id') | ||||
Show All 23 Lines |