config = $config; $this->table = $this->config->dbTableGroups; $this->DBGroup = $this->config->dbProfile; $this->tempUseSoftDeletes = $this->config->dbSoftDeleteGroups; $this->tempReturnType = $this->config->dbReturnType; $this->validationRules['name'] = 'required|is_unique[' . $this->table . '.name,id,{id}]'; $this->validationMessages = [ 'name' => [ 'required' => lang('Aauth.requiredGroupName'), 'is_unique' => lang('Aauth.existsAlreadyGroup'), ], ]; } /** * Checks if group exist by group id * * @param integer $groupId Group id * * @return boolean */ public function existsById(int $groupId) { $builder = $this->builder(); if ($this->tempUseSoftDeletes === true) { $builder->where($this->deletedField, 0); } $builder->where($this->primaryKey, $groupId); return ($builder->countAllResults() ? true : false); } /** * Get group by group name * * @param string $groupName Group name * * @return boolean */ public function getByName(string $groupName) { $builder = $this->builder(); if ($this->tempUseSoftDeletes === true) { $builder->where($this->deletedField, 0); } $builder->where('name', $groupName); if (! $group = $builder->get()->getFirstRow($this->tempReturnType)) { return false; } return $group; } }