Changeset View
Changeset View
Standalone View
Standalone View
src/app/Console/Commands/Group/AddMemberCommand.php
Show All 24 Lines | class AddMemberCommand extends Command | ||||
* Execute the console command. | * Execute the console command. | ||||
* | * | ||||
* @return mixed | * @return mixed | ||||
*/ | */ | ||||
public function handle() | public function handle() | ||||
{ | { | ||||
$input = $this->argument('group'); | $input = $this->argument('group'); | ||||
$member = \strtolower($this->argument('member')); | $member = \strtolower($this->argument('member')); | ||||
$group = $this->getObject(\App\Group::class, $input, 'email'); | $group = $this->getGroup($input); | ||||
if (empty($group)) { | if (empty($group)) { | ||||
$this->error("Group {$input} does not exist."); | $this->error("Group {$input} does not exist."); | ||||
return 1; | return 1; | ||||
} | } | ||||
if (in_array($member, $group->members)) { | if (in_array($member, $group->members)) { | ||||
$this->error("{$member}: Already exists in the group."); | $this->error("{$member}: Already exists in the group."); | ||||
Show All 15 Lines |