From d0f669ce8efd69f9e7d57f0ae308916094e1d102 Mon Sep 17 00:00:00 2001 From: Salem Ouerdani Date: Sat, 1 Jun 2019 00:43:00 +0100 Subject: [PATCH] [Bug][BC] Filters should be merged with user's ones instead of overriding --- src/Action.php | 2 +- src/LinkAction.php | 4 ++-- src/UnlinkAction.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Action.php b/src/Action.php index d683ed8..8ee7e6f 100644 --- a/src/Action.php +++ b/src/Action.php @@ -107,7 +107,7 @@ public function findCurrentModels($IDs) $getter = 'get' . $this->relationName; $relModel = $this->getRelativeModel(); - $q = $relModel->$getter()->where([$pk => $ids]); + $q = $relModel->$getter()->andWhere([$pk => $ids]); $ci = count($ids); $model = $ci > 1 ? $q->all() : $q->one(); diff --git a/src/LinkAction.php b/src/LinkAction.php index 5fe7224..c63a03b 100755 --- a/src/LinkAction.php +++ b/src/LinkAction.php @@ -52,10 +52,10 @@ public function run($IDs) $to_link = []; foreach ($ids as $pk_value) { - $linked = $relModel->$getter()->where([$pk => $pk_value])->exists(); + $linked = $relModel->$getter()->andWhere([$pk => $pk_value])->exists(); if ($linked === false) { - $exist = $modelClass::find()->where([$pk => $pk_value])->exists(); + $exist = $modelClass::find()->andWhere([$pk => $pk_value])->exists(); if ($exist === false) throw new NotFoundHttpException(StringHelper::basename($modelClass) . " '$pk_value' not found."); diff --git a/src/UnlinkAction.php b/src/UnlinkAction.php index 602e0a7..cc8448f 100755 --- a/src/UnlinkAction.php +++ b/src/UnlinkAction.php @@ -39,7 +39,7 @@ public function run($IDs) $to_unlink = []; foreach ($ids as $pk_value) { - $linked = $relModel->$getter()->where([$pk => $pk_value])->exists(); + $linked = $relModel->$getter()->andWhere([$pk => $pk_value])->exists(); if ($linked === true) $to_unlink []= $this->findModel($pk_value); else throw new BadRequestHttpException(StringHelper::basename($modelClass) . " '$pk_value' not linked to ".StringHelper::basename($this->relativeClass)." '$this->relative_id'."); }