Changeset View
Changeset View
Standalone View
Standalone View
src/app/Console/Commands/PackageSkus.php
<?php | <?php | ||||
namespace App\Console\Commands; | namespace App\Console\Commands; | ||||
use App\Console\Command; | |||||
use App\Package; | use App\Package; | ||||
use Illuminate\Console\Command; | |||||
class PackageSkus extends Command | class PackageSkus extends Command | ||||
{ | { | ||||
/** | /** | ||||
* The name and signature of the console command. | * The name and signature of the console command. | ||||
* | * | ||||
* @var string | * @var string | ||||
*/ | */ | ||||
protected $signature = 'package:skus'; | protected $signature = 'package:skus'; | ||||
/** | /** | ||||
* The console command description. | * The console command description. | ||||
* | * | ||||
* @var string | * @var string | ||||
*/ | */ | ||||
protected $description = "List SKUs for packages."; | protected $description = "List SKUs for packages."; | ||||
/** | /** | ||||
* 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() | ||||
{ | { | ||||
$packages = Package::all(); | $packages = Package::withEnvTenant()->get(); | ||||
foreach ($packages as $package) { | foreach ($packages as $package) { | ||||
$this->info(sprintf("Package: %s", $package->title)); | $this->info(sprintf("Package: %s", $package->title)); | ||||
foreach ($package->skus as $sku) { | foreach ($package->skus as $sku) { | ||||
$this->info(sprintf(" SKU: %s (%d)", $sku->title, $sku->pivot->qty)); | $this->info(sprintf(" SKU: %s (%d)", $sku->title, $sku->pivot->qty)); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } |