Changeset View
Changeset View
Standalone View
Standalone View
src/app/Console/Commands/Discount/MergeCommand.php
Show First 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | class MergeCommand extends Command | ||||
/** | /** | ||||
* Execute the console command. | * Execute the console command. | ||||
* | * | ||||
* @return mixed | * @return mixed | ||||
*/ | */ | ||||
public function handle() | public function handle() | ||||
{ | { | ||||
$source = \App\Discount::find($this->argument('source')); | $source = \App\Discount::withEnvTenant()->find($this->argument('source')); | ||||
if (!$source) { | if (!$source) { | ||||
$this->error("No such source discount: {$source}"); | $this->error("No such source discount: {$source}"); | ||||
return 1; | return 1; | ||||
} | } | ||||
$target = \App\Discount::find($this->argument('target')); | $target = \App\Discount::withEnvTenant()->find($this->argument('target')); | ||||
if (!$target) { | if (!$target) { | ||||
$this->error("No such target discount: {$target}"); | $this->error("No such target discount: {$target}"); | ||||
return 1; | return 1; | ||||
} | } | ||||
if ($source->discount !== $target->discount) { | if ($source->discount !== $target->discount) { | ||||
$this->error("Can't merge two discounts that have different rates"); | $this->error("Can't merge two discounts that have different rates"); | ||||
Show All 17 Lines |