Changeset View
Changeset View
Standalone View
Standalone View
src/app/Console/Commands/WalletSetBalance.php
<?php | <?php | ||||
namespace App\Console\Commands; | namespace App\Console\Commands; | ||||
use Illuminate\Console\Command; | use App\Console\Command; | ||||
class WalletSetBalance extends Command | class WalletSetBalance 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:set-balance {wallet} {balance}'; | protected $signature = 'wallet:set-balance {wallet} {balance}'; | ||||
/** | /** | ||||
* The console command description. | * The console command description. | ||||
* | * | ||||
* @var string | * @var string | ||||
*/ | */ | ||||
protected $description = 'Set the balance of a wallet'; | protected $description = 'Set the balance of a wallet'; | ||||
/** | /** | ||||
* 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() | ||||
{ | { | ||||
$wallet = \App\Wallet::find($this->argument('wallet')); | $wallet = $this->getWallet($this->argument('wallet')); | ||||
if (!$wallet) { | if (!$wallet) { | ||||
return 1; | return 1; | ||||
} | } | ||||
$wallet->balance = (int)($this->argument('balance')); | $wallet->balance = (int) $this->argument('balance'); | ||||
$wallet->save(); | $wallet->save(); | ||||
} | } | ||||
} | } |