From b005571f8428b0a4bcb63594c7e651aae884e329 Mon Sep 17 00:00:00 2001 From: joycezhang <787027175@qq.com> Date: Tue, 7 Feb 2023 15:13:43 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8(repository):=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E8=AE=B0=E5=BD=95=E6=98=AF=E5=90=A6=E5=AD=98?= =?UTF-8?q?=E5=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Repositories/BaseRepository.php | 8 ++++---- src/Repositories/Interfaces/BaseInterface.php | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/Repositories/BaseRepository.php b/src/Repositories/BaseRepository.php index d21682f..320aa63 100644 --- a/src/Repositories/BaseRepository.php +++ b/src/Repositories/BaseRepository.php @@ -193,11 +193,11 @@ public function findWhereNotIn(string $field, array $values, $columns = ['*']) /** * 判断数据是否存在,存在返回true 不存在返回false * @param array $where 查询条件 - * @return boolean true | false + * @return bool * @throws RepositoryException * @throws \Illuminate\Contracts\Container\BindingResolutionException */ - public function existsWhere(array $where) + public function existsWhere(array $where): bool { $this->applyConditions($where); $model = $this->model->exists(); @@ -208,11 +208,11 @@ public function existsWhere(array $where) /** * 判断数据是否存在,存在返回 false 不存在返回 true * @param array $where - * @return mixed + * @return bool * @throws RepositoryException * @throws \Illuminate\Contracts\Container\BindingResolutionException */ - public function doesntExistWhere(array $where) + public function doesntExistWhere(array $where): bool { $this->applyConditions($where); $model = $this->model->doesntExist(); diff --git a/src/Repositories/Interfaces/BaseInterface.php b/src/Repositories/Interfaces/BaseInterface.php index da6ef4f..ea8cdc9 100644 --- a/src/Repositories/Interfaces/BaseInterface.php +++ b/src/Repositories/Interfaces/BaseInterface.php @@ -83,6 +83,20 @@ public function findWhereIn(string $field, array $values, $columns = ['*']); */ public function findWhereNotIn(string $field, array $values, $columns = ['*']); + /** + * 判断数据是否存在,存在返回true 不存在返回false + * @param array $where 查询条件 + * @return bool + */ + public function existsWhere(array $where): bool; + + /** + * 判断数据是否存在,存在返回 false 不存在返回 true + * @param array $where + * @return bool + */ + public function doesntExistWhere(array $where): bool; + /** * 根据主键id获取单条数据 * @param int $id 主键id