findDuplicate($user_id, $type, $title, false, $exclude_id); } /** * Архивная (is_delete=1) группа с тем же названием у пользователя. * * @param int $user_id * @param string $type * @param string $title * @param int|null $exclude_id * @return object|false */ public function findArchivedDuplicate(int $user_id, string $type, string $title, ?int $exclude_id = null): mixed { return $this->findDuplicate($user_id, $type, $title, true, $exclude_id); } /** * @param int $user_id * @param string $type * @param string $title * @param bool $is_delete * @param int|null $exclude_id * @return object|false */ protected function findDuplicate(int $user_id, string $type, string $title, bool $is_delete, ?int $exclude_id): mixed { $pdo = $this->pdo->pdo(); $where = "user_id = $user_id" . ' AND type = ' . $pdo->quote($type) . ' AND is_delete = ' . ($is_delete ? 1 : 0) . ' AND title = ' . $pdo->quote($title); if ($exclude_id !== null) { $where .= " AND id != $exclude_id"; } return $this->getItemWhere($where); } /** * Активные группы пользователя. * * @param int $user_id * @return object[] */ public function getForUser(int $user_id): array { return $this->getList('*', ['user_id' => $user_id, 'is_delete' => 0], '`order`') ?: []; } }