Changeset View
Changeset View
Standalone View
Standalone View
src/app/Console/Commands/User/AddAliasCommand.php
- This file was moved from src/app/Console/Commands/UserAddAlias.php.
<?php | <?php | ||||
namespace App\Console\Commands; | namespace App\Console\Commands\User; | ||||
use App\Console\Command; | use App\Console\Command; | ||||
use App\Http\Controllers\API\V4\UsersController; | use App\Http\Controllers\API\V4\UsersController; | ||||
class UserAddAlias extends Command | class AddAliasCommand 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:add-alias {--force} {user} {alias}'; | protected $signature = 'user:add-alias {--force} {user} {alias}'; | ||||
Show All 9 Lines | class AddAliasCommand extends Command | ||||
* | * | ||||
* @return mixed | * @return mixed | ||||
*/ | */ | ||||
public function handle() | public function handle() | ||||
{ | { | ||||
$user = $this->getUser($this->argument('user')); | $user = $this->getUser($this->argument('user')); | ||||
if (!$user) { | if (!$user) { | ||||
$this->error("User not found."); | |||||
return 1; | return 1; | ||||
} | } | ||||
$alias = \strtolower($this->argument('alias')); | $alias = \strtolower($this->argument('alias')); | ||||
// Check if the alias already exists | // Check if the alias already exists | ||||
if ($user->aliases()->where('alias', $alias)->first()) { | if ($user->aliases()->where('alias', $alias)->first()) { | ||||
$this->error("Address is already assigned to the user."); | $this->error("Address is already assigned to the user."); | ||||
Show All 18 Lines |