build() public static method

Create a new group.
public static build ( string $nameSingular, string $namePlural, string $color, string $icon ) : static
$nameSingular string
$namePlural string
$color string
$icon string
return static
コード例 #1
0
ファイル: CreateGroupHandler.php プロジェクト: Luceos/core
 /**
  * @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;
 }