Changeset View
Changeset View
Standalone View
Standalone View
src/app/Console/Commands/UserDomains.php
<?php | <?php | ||||
namespace App\Console\Commands; | namespace App\Console\Commands; | ||||
use App\Domain; | use App\Console\Command; | ||||
use App\User; | |||||
use Illuminate\Console\Command; | |||||
use Illuminate\Support\Facades\DB; | |||||
class UserDomains extends Command | class UserDomains extends Command | ||||
{ | { | ||||
/** | /** | ||||
* The name and signature of the console command. | * The name and signature of the console command. | ||||
* | * | ||||
* @var string | * @var string | ||||
*/ | */ | ||||
protected $signature = 'user:domains {userid}'; | protected $signature = 'user:domains {userid}'; | ||||
/** | /** | ||||
* The console command description. | * The console command description. | ||||
* | * | ||||
* @var string | * @var string | ||||
*/ | */ | ||||
protected $description = 'Command description'; | protected $description = 'Command description'; | ||||
/** | /** | ||||
* 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() | ||||
{ | { | ||||
$user = User::where('email', $this->argument('userid'))->first(); | $user = $this->getUser($this->argument('userid')); | ||||
if (!$user) { | if (!$user) { | ||||
return 1; | return 1; | ||||
} | } | ||||
foreach ($user->domains() as $domain) { | foreach ($user->domains() as $domain) { | ||||
$this->info("{$domain->namespace}"); | $this->info("{$domain->namespace}"); | ||||
} | } | ||||
} | } | ||||
} | } |