public function actionCreate()
 {
     $model = new Model();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         $module = $this->module;
         return $this->redirect(['update', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 public function search($params)
 {
     $query = ModelModel::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => new \yii\data\Sort(['attributes' => ['name', 'id']])]);
     $this->load($params);
     if (!$this->validate()) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'category_id' => $this->category_id, 'mark_id' => $this->mark_id]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'text', $this->text])->andFilterWhere(['like', 'code', $this->code])->andFilterWhere(['like', 'category_id', $this->category_id]);
     return $dataProvider;
 }
Example #3
0
 public function getModels()
 {
     return $this->hasMany(Model::className(), ['id' => 'model_id'])->viaTable('{{%autocatalog_model_to_category}}', ['category_id' => 'id'])->available();
 }