/**
* @param CreateGroup $command
* @return Group
* @throws PermissionDeniedException
*/
public function handle(CreateGroup $command)
{
$actor = $command->actor;
$data = $command->data;
$this->assertCan($actor, 'createGroup');
$group = Group::build(array_get($data, 'attributes.nameSingular'), array_get($data, 'attributes.namePlural'), array_get($data, 'attributes.color'), array_get($data, 'attributes.icon'));
$this->events->fire(new GroupWillBeSaved($group, $actor, $data));
$this->validator->assertValid($group->getAttributes());
$group->save();
$this->dispatchEventsFor($group, $actor);
return $group;
}