Changeset View
Changeset View
Standalone View
Standalone View
src/app/Console/Commands/Sku/ListUsers.php
<?php | <?php | ||||
namespace App\Console\Commands\Sku; | namespace App\Console\Commands\Sku; | ||||
use Illuminate\Console\Command; | use App\Console\Command; | ||||
class ListUsers extends Command | class ListUsers extends Command | ||||
{ | { | ||||
/** | /** | ||||
* The name and signature of the console command. | * The name and signature of the console command. | ||||
* | * | ||||
* @var string | * @var string | ||||
*/ | */ | ||||
protected $signature = 'sku:list-users {sku}'; | protected $signature = 'sku:list-users {sku}'; | ||||
/** | /** | ||||
* The console command description. | * The console command description. | ||||
* | * | ||||
* @var string | * @var string | ||||
*/ | */ | ||||
protected $description = 'List users with the SKU entitlement.'; | protected $description = 'List users with the SKU entitlement.'; | ||||
/** | /** | ||||
* Execute the console command. | * Execute the console command. | ||||
* | * | ||||
* @return mixed | * @return mixed | ||||
*/ | */ | ||||
public function handle() | public function handle() | ||||
{ | { | ||||
$sku = \App\Sku::find($this->argument('sku')); | $sku = $this->getObject(\App\Sku::class, $this->argument('sku'), 'title'); | ||||
if (!$sku) { | |||||
$sku = \App\Sku::where('title', $this->argument('sku'))->first(); | |||||
} | |||||
if (!$sku) { | if (!$sku) { | ||||
$this->error("Unable to find the SKU."); | $this->error("Unable to find the SKU."); | ||||
return 1; | return 1; | ||||
} | } | ||||
$fn = function ($entitlement) { | $fn = function ($entitlement) { | ||||
$user_id = $entitlement->user_id; | $user_id = $entitlement->user_id; | ||||
Show All 22 Lines |