示例#1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Mark::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]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'degree', $this->degree]);
     return $dataProvider;
 }
示例#2
0
文件: Image.php 项目: sly13/pivasik
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getMarks()
 {
     return $this->hasMany(Mark::className(), ['image_id' => 'id']);
 }
示例#3
0
文件: Brand.php 项目: sly13/pivasik
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getMark()
 {
     return $this->hasOne(Mark::className(), ['id' => 'mark_id']);
 }
示例#4
0
 /**
  * Finds the Mark model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Mark the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Mark::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
示例#5
0
文件: _form.php 项目: sly13/pivasik
<div class="product-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'image_id')->textInput();
?>

    <?php 
echo $form->field($model, 'brand_id')->dropDownList(ArrayHelper::map(Brand::find()->all(), 'id', 'name'), ['prompt' => 'Выберите бренд']);
?>

    <?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' => 'Выберите магазин']);
?>