Changeset View
Changeset View
Standalone View
Standalone View
src/app/Console/Commands/UserAddAlias.php
<?php | <?php | ||||
namespace App\Console\Commands; | namespace App\Console\Commands; | ||||
use App\Http\Controllers\API\V4\UsersController; | use App\Http\Controllers\API\V4\UsersController; | ||||
use Illuminate\Console\Command; | use Illuminate\Console\Command; | ||||
class UserAddAlias extends Command | class UserAddAlias 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 {user} {alias}'; | protected $signature = 'user:add-alias {--force} {user} {alias}'; | ||||
/** | /** | ||||
* The console command description. | * The console command description. | ||||
* | * | ||||
* @var string | * @var string | ||||
*/ | */ | ||||
protected $description = 'Add an email alias to a user'; | protected $description = 'Add an email alias to a user (forcefully)'; | ||||
/** | /** | ||||
* Create a new command instance. | * Create a new command instance. | ||||
* | * | ||||
* @return void | * @return void | ||||
*/ | */ | ||||
public function __construct() | public function __construct() | ||||
{ | { | ||||
Show All 22 Lines | public function handle() | ||||
} | } | ||||
$controller = $user->wallet()->owner; | $controller = $user->wallet()->owner; | ||||
// Validate the alias | // Validate the alias | ||||
$error = UsersController::validateEmail($alias, $controller, true); | $error = UsersController::validateEmail($alias, $controller, true); | ||||
if ($error) { | if ($error) { | ||||
if (!$this->option('force')) { | |||||
$this->error($error); | $this->error($error); | ||||
return 1; | return 1; | ||||
} | } | ||||
} | |||||
$user->aliases()->create(['alias' => $alias]); | $user->aliases()->create(['alias' => $alias]); | ||||
} | } | ||||
} | } |