Changeset View
Changeset View
Standalone View
Standalone View
src/app/Console/Commands/WalletSetBalance.php
- This file was copied from src/app/Console/Commands/DomainList.php.
<?php | <?php | ||||
namespace App\Console\Commands; | namespace App\Console\Commands; | ||||
use App\Domain; | |||||
use Illuminate\Console\Command; | use Illuminate\Console\Command; | ||||
class DomainList 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 = 'domain:list'; | protected $signature = 'wallet:set-balance {wallet} {balance}'; | ||||
machniak: Should this command be available in production? Maybe not, then move it to… | |||||
/** | /** | ||||
* The console command description. | * The console command description. | ||||
* | * | ||||
* @var string | * @var string | ||||
*/ | */ | ||||
protected $description = 'List domains'; | protected $description = 'Set the balance of a wallet'; | ||||
/** | /** | ||||
* Create a new command instance. | * Create a new command instance. | ||||
* | * | ||||
* @return void | * @return void | ||||
*/ | */ | ||||
public function __construct() | public function __construct() | ||||
{ | { | ||||
parent::__construct(); | parent::__construct(); | ||||
} | } | ||||
/** | /** | ||||
* Execute the console command. | * Execute the console command. | ||||
* | * | ||||
* @return mixed | * @return mixed | ||||
*/ | */ | ||||
public function handle() | public function handle() | ||||
{ | { | ||||
$domains = Domain::withTrashed()->orderBy('namespace')->each( | $wallet = \App\Wallet::find($this->argument('wallet')); | ||||
function ($domain) { | |||||
$this->info($domain->namespace); | if (!$wallet) { | ||||
return 1; | |||||
} | } | ||||
); | |||||
$wallet->balance = (int)($this->argument('balance')); | |||||
$wallet->save(); | |||||
Not Done Inline Actions\App\Wallet::find($this->argument('wallet')); machniak: \App\Wallet::find($this->argument('wallet')); | |||||
} | } | ||||
} | } |
Should this command be available in production? Maybe not, then move it to app/Console/Development/DomainList.php