Flarum\Core\Repository\GroupRepository::findOrFail PHP Метод

findOrFail() публичный Метод

Find a user by ID, optionally making sure it is visible to a certain user, or throw an exception.
public findOrFail ( integer $id, User $actor = null ) : Group
$id integer
$actor Flarum\Core\User
Результат Flarum\Core\Group
    public function findOrFail($id, User $actor = null)
    {
        $query = Group::where('id', $id);
        return $this->scopeVisibleTo($query, $actor)->firstOrFail();
    }

Usage Example

Пример #1
0
 /**
  * @param DeleteGroup $command
  * @return \Flarum\Core\Group
  * @throws PermissionDeniedException
  */
 public function handle(DeleteGroup $command)
 {
     $actor = $command->actor;
     $group = $this->groups->findOrFail($command->groupId, $actor);
     $this->assertCan($actor, 'delete', $group);
     $this->events->fire(new GroupWillBeDeleted($group, $actor, $command->data));
     $group->delete();
     $this->dispatchEventsFor($group, $actor);
     return $group;
 }
All Usage Examples Of Flarum\Core\Repository\GroupRepository::findOrFail