- ProfileSearchForm now contains achievements array. Profile index action by id, by params response now contains achievements array

This commit is contained in:
Korzinkayablok 2021-09-14 14:43:09 +03:00
parent 9ebfb3323c
commit b2b3a7b462

View File

@ -20,6 +20,8 @@ class ProfileSearchForm extends Model
public $limit = 10; public $limit = 10;
public $offset = 0; public $offset = 0;
public $skills; public $skills;
public $achievements;
public $position_id; public $position_id;
public $id; public $id;
@ -28,6 +30,7 @@ class ProfileSearchForm extends Model
return [ return [
[['id', 'limit', 'offset', 'position_id'], 'safe'], [['id', 'limit', 'offset', 'position_id'], 'safe'],
[['skills'], 'checkIsArray'], [['skills'], 'checkIsArray'],
[['achievements'], 'checkIsArray'],
]; ];
} }
@ -45,6 +48,7 @@ class ProfileSearchForm extends Model
return UserCard::find() return UserCard::find()
->where(['id' => $this->id]) ->where(['id' => $this->id])
->with(['skillValues']) ->with(['skillValues'])
->with(['achievements'])
->asArray() ->asArray()
->one(); ->one();
} }
@ -67,6 +71,16 @@ class ProfileSearchForm extends Model
$model->joinWith('skillValues'); $model->joinWith('skillValues');
} }
if($this->achievements){
$model->joinWith(['achievements']);
$this->achievements = explode(',', $this->achievements);
$model->where(['achievement_user_card.achievement_id' => $this->achievements]);
$model->having('COUNT(DISTINCT achievement_id) = ' . count($this->achievements));
}
else{
$model->joinWith('achievements');
}
$model->andFilterWhere(['position_id' => $this->position_id]); $model->andFilterWhere(['position_id' => $this->position_id]);
$model->andWhere(['status' => [4, 12]]); $model->andWhere(['status' => [4, 12]]);