public function actionUpdate($id)
 {
     $model = CarModel::findOne($id);
     if ($model->load(\Yii::$app->request->post())) {
         if ($model->validate() && $model->save()) {
             return $this->redirect(['index']);
         }
     }
     return $this->render('form', ['model' => $model]);
 }
Пример #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = CarModel::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(['id' => $this->id]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
Пример #3
0
 public static function getTableCarModel()
 {
     $cat = CarModel::find()->all();
     $cat = ArrayHelper::map($cat, 'id', 'name');
     return $cat;
 }
Пример #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getIdCarModel()
 {
     return $this->hasOne(CarModel::className(), ['id_car_model' => 'id_car_model']);
 }
Пример #5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCarModels()
 {
     return $this->hasMany(CarModel::className(), ['id_car_make' => 'id_car_make']);
 }
Пример #6
0
 /**
  * Returns the array of possible user status values.
  *
  * @return array
  */
 public function getPassengerCarsModelsList()
 {
     $transport_operations = ArrayHelper::map(CarModel::find()->where(['id_car_make' => $this->mark])->all(), 'id_car_model', 'name');
     $items = [];
     foreach ($transport_operations as $key => $value) {
         $items[$key] = Yii::t('transport', $value);
     }
     return $items;
 }