From 8c9b5f04d41ca3976d1090fda2a67b33243aa3dd Mon Sep 17 00:00:00 2001 From: andrey Date: Fri, 25 Jun 2021 18:19:02 +0300 Subject: [PATCH] api search profile fix --- frontend/modules/api/models/ProfileSearchForm.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/frontend/modules/api/models/ProfileSearchForm.php b/frontend/modules/api/models/ProfileSearchForm.php index b63c4a4..481bf35 100644 --- a/frontend/modules/api/models/ProfileSearchForm.php +++ b/frontend/modules/api/models/ProfileSearchForm.php @@ -5,6 +5,7 @@ namespace frontend\modules\api\models; use backend\modules\card\models\UserCard; +use common\classes\Debug; use yii\base\Model; /** @@ -52,13 +53,18 @@ class ProfileSearchForm extends Model public function byParams() { - $model = UserCard::find() - ->joinWith(['skillValues']); + $model = UserCard::find(); + if($this->skills){ + $model->joinWith(['skillValues']); + Debug::prn(123); $this->skills = explode(',', $this->skills); $model->where(['card_skill.skill_id' => $this->skills]); } + else{ + $model->with('skillValues'); + } return $model->limit($this->limit) ->offset($this->offset)->asArray()->all();