/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Shop::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['owner_id' => $this->owner_id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'tags', $this->tags]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getShopName() { return $this->hasOne(Shop::className(), ['name' => 'shop_name']); }
/** * Finds the Shop model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return Shop the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Shop::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }