public function search($params) { $query = Property::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'category_id' => $this->category_id, 'client_id' => $this->client_id]); $query->andFilterWhere(['like', 'name', $this->name]); return $dataProvider; }
public function actionGetClientByProperty() { $ident = yii::$app->request->post('ident'); if (!$ident) { return json_encode(['result' => 'fail', 'client_id' => $client->id]); } $property = Property::find()->where(['name' => $ident])->one(); if ($client = $property->client) { $json = ['result' => 'success', 'client_id' => $client->id]; } else { $json = ['result' => 'fail']; } return json_encode($json); }