Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2485195
AddAliasCommand.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
AddAliasCommand.php
View Options
<?php
namespace
App\Console\Commands\User
;
use
App\Console\Command
;
use
App\Http\Controllers\API\V4\UsersController
;
class
AddAliasCommand
extends
Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected
$signature
=
'user:add-alias {--force} {user} {alias}'
;
/**
* The console command description.
*
* @var string
*/
protected
$description
=
'Add an email alias to a user (forcefully)'
;
/**
* Execute the console command.
*
* @return mixed
*/
public
function
handle
()
{
$user
=
$this
->
getUser
(
$this
->
argument
(
'user'
));
if
(!
$user
)
{
$this
->
error
(
"User not found."
);
return
1
;
}
$alias
=
\strtolower
(
$this
->
argument
(
'alias'
));
// Check if the alias already exists
if
(
$user
->
aliases
()->
where
(
'alias'
,
$alias
)->
first
())
{
$this
->
error
(
"Address is already assigned to the user."
);
return
1
;
}
$controller
=
$user
->
wallet
()->
owner
;
// Validate the alias
$error
=
UsersController
::
validateAlias
(
$alias
,
$controller
);
if
(
$error
)
{
if
(!
$this
->
option
(
'force'
))
{
$this
->
error
(
$error
);
return
1
;
}
}
$user
->
aliases
()->
create
([
'alias'
=>
$alias
]);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Nov 21, 7:11 AM (1 d, 16 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
387411
Default Alt Text
AddAliasCommand.php (1 KB)
Attached To
Mode
R2 kolab
Attached
Detach File
Event Timeline
Log In to Comment