public function actionInterior() { if (Yii::$app->user->isGuest) { $this->redirect(Yii::$app->user->loginUrl); } $model = BInterior::find()->where(['site' => 1])->one(); if (!$model) { $model = new BInterior(); $model->site = 1; } if ($model->load(Yii::$app->request->post()) && $model->save()) { if ($_POST[id_img]) { $array_id_img = json_decode($model->images); if (is_array($array_id_img)) { $new_pre_images = array_merge($array_id_img, $_POST[id_img]); $model->images = json_encode(array_unique($new_pre_images)); $model->save(); } else { $model->images = json_encode($_POST[id_img]); $model->save(); } } $model->save(); return $this->redirect('interior', ['model' => $model, 'success' => true]); } return $this->render('interior', ['model' => $model]); }