Changeset View
Changeset View
Standalone View
Standalone View
src/app/Console/Commands/SharedFolder/AddAliasCommand.php
<?php | <?php | ||||
namespace App\Console\Commands\SharedFolder; | namespace App\Console\Commands\SharedFolder; | ||||
use App\Console\Command; | use App\Console\Command; | ||||
use App\Http\Controllers\API\V4\UsersController; | use App\Http\Controllers\API\V4\SharedFoldersController; | ||||
class AddAliasCommand 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 | ||||
*/ | */ | ||||
Show All 24 Lines | public function handle() | ||||
// Check if the alias already exists | // Check if the alias already exists | ||||
if ($folder->aliases()->where('alias', $alias)->first()) { | if ($folder->aliases()->where('alias', $alias)->first()) { | ||||
$this->error("Address is already assigned to the folder."); | $this->error("Address is already assigned to the folder."); | ||||
return 1; | return 1; | ||||
} | } | ||||
// Validate the alias | // Validate the alias | ||||
$error = UsersController::validateAlias($alias, $folder->walletOwner()); | $domain = explode('@', $folder->email, 2)[1]; | ||||
$error = SharedFoldersController::validateAlias($alias, $folder->walletOwner(), $folder->name, $domain); | |||||
if ($error) { | if ($error) { | ||||
if (!$this->option('force')) { | if (!$this->option('force')) { | ||||
$this->error($error); | $this->error($error); | ||||
return 1; | return 1; | ||||
} | } | ||||
} | } | ||||
$folder->aliases()->create(['alias' => $alias]); | $folder->aliases()->create(['alias' => $alias]); | ||||
} | } | ||||
} | } |