Changeset View
Changeset View
Standalone View
Standalone View
src/app/Console/Commands/Wallet/GetDiscount.php
- This file was moved from src/app/Console/Commands/WalletGetDiscount.php.
<?php | <?php | ||||
namespace App\Console\Commands; | namespace App\Console\Commands\Wallet; | ||||
use Illuminate\Console\Command; | use App\Console\Command; | ||||
class WalletGetDiscount extends Command | class GetDiscount 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:get-discount {wallet}'; | protected $signature = 'wallet:get-discount {wallet}'; | ||||
/** | /** | ||||
* The console command description. | * The console command description. | ||||
* | * | ||||
* @var string | * @var string | ||||
*/ | */ | ||||
protected $description = 'Display the existing discount to a wallet, if any.'; | protected $description = 'Display the existing discount to a wallet, if any.'; | ||||
/** | /** | ||||
* 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 = \App\Wallet::find($this->argument('wallet')); | ||||
if (!$wallet) { | if (!$wallet) { | ||||
$this->error("Wallet not found"); | |||||
return 1; | return 1; | ||||
} | } | ||||
if (!$wallet->discount) { | if (!$wallet->discount) { | ||||
$this->info("No discount on this wallet."); | $this->info("No discount on this wallet."); | ||||
return 0; | return 0; | ||||
} | } | ||||
$this->info($wallet->discount->discount); | $this->info($wallet->discount->discount); | ||||
} | } | ||||
} | } |