Changeset View
Changeset View
Standalone View
Standalone View
src/app/Console/Commands/WalletUntil.php
<?php | <?php | ||||
namespace App\Console\Commands; | namespace App\Console\Commands; | ||||
use Illuminate\Console\Command; | use App\Console\Command; | ||||
class WalletUntil extends Command | class WalletUntil 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:until {wallet}'; | protected $signature = 'wallet:until {wallet}'; | ||||
/** | /** | ||||
* The console command description. | * The console command description. | ||||
* | * | ||||
* @var string | * @var string | ||||
*/ | */ | ||||
protected $description = 'Show until when the balance on a wallet lasts.'; | protected $description = 'Show until when the balance on a wallet lasts.'; | ||||
/** | /** | ||||
* 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; | ||||
} | } | ||||
$until = $wallet->balanceLastsUntil(); | $until = $wallet->balanceLastsUntil(); | ||||
$this->info("Lasts until: " . ($until ? $until->toDateString() : 'unknown')); | $this->info("Lasts until: " . ($until ? $until->toDateString() : 'unknown')); | ||||
} | } | ||||
} | } |