validation = $validation; $this->tokenRepository = $tokenRepository; parent::__construct(); } /** * Execute the console command. * * @return int */ public function handle() { if ($this->option('name')=='') { $accessTokenName = 'CLI Auth Token'; } if ($this->argument('user')=='') { return false; } if ($user = User::find($this->argument('user'))) { if ($this->option('key-only')=='true') { $this->info($user->createToken($accessTokenName)->accessToken); } else { $this->warn('Your API Token has been created. Be sure to copy this token now, as it will not be accessible again.'); $this->info('API Token User: '.$user->present()->fullName.' ('.$user->username.')'); $this->info('API Token Name: '.$accessTokenName); $this->info('API Token: '.$user->createToken($accessTokenName)->accessToken); } } else { return $this->error('ERROR: Invalid user. API key was not created.'); } } }