/** * 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 return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'image_id' => $this->image_id, 'address_id' => $this->address_id]); $query->andFilterWhere(['like', 'name', $this->name]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getShops() { return $this->hasMany(Shop::className(), ['image_id' => 'id']); }
?> <?php echo $form->field($model, 'mark_id')->dropDownList(ArrayHelper::map(Mark::find()->all(), 'id', 'name'), ['prompt' => 'Выберите марку']); ?> <?php echo $form->field($model, 'typebeer_id')->dropDownList(ArrayHelper::map(Typebeer::find()->all(), 'id', 'name'), ['prompt' => 'Выберите тип']); ?> <?php echo $form->field($model, 'size_id')->dropDownList(ArrayHelper::map(Size::find()->all(), 'id', 'volume'), ['prompt' => 'Выберите объём']); ?> <?php echo $form->field($model, 'shop_id')->dropDownList(ArrayHelper::map(Shop::find()->all(), 'id', 'name'), ['prompt' => 'Выберите магазин']); ?> <?php echo $form->field($model, 'price')->textInput(); ?> <?php echo $form->field($model, 'date')->textInput(); ?> <?php echo $form->field($model, 'created')->textInput(); ?>
/** * Finds the Shop model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $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.'); } }
/** * @return \yii\db\ActiveQuery */ public function getShop() { return $this->hasOne(Shop::className(), ['id' => 'shop_id']); }