Changeset View
Changeset View
Standalone View
Standalone View
src/app/Console/Commands/User/DomainsCommand.php
<?php | <?php | ||||
namespace App\Console\Commands\User; | namespace App\Console\Commands\User; | ||||
use App\Console\Command; | use App\Console\ObjectRelationListCommand; | ||||
class DomainsCommand extends Command | class DomainsCommand extends ObjectRelationListCommand | ||||
{ | { | ||||
/** | protected $objectClass = \App\User::class; | ||||
* The name and signature of the console command. | protected $objectName = 'user'; | ||||
* | protected $objectTitle = 'email'; | ||||
* @var string | protected $objectRelation = 'domains'; | ||||
*/ | protected $objectRelationArgs = [true, false]; | ||||
protected $signature = 'user:domains {user}'; | |||||
/** | |||||
* The console command description. | |||||
* | |||||
* @var string | |||||
*/ | |||||
protected $description = "List a user's domains."; | |||||
/** | |||||
* Execute the console command. | |||||
* | |||||
* @return mixed | |||||
*/ | |||||
public function handle() | |||||
{ | |||||
$user = $this->getUser($this->argument('user')); | |||||
if (!$user) { | |||||
$this->error("User not found."); | |||||
return 1; | |||||
} | |||||
foreach ($user->domains() as $domain) { | |||||
$this->info($domain->namespace); | |||||
} | |||||
} | |||||
} | } |