/** * Creates a new Ads model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Ads(); if ($model->load(Yii::$app->request->post())) { if (isset($_FILES) && $_FILES) { $model->imageFile = UploadedFile::getInstance($model, 'imageFile'); if ($model->imageFile) { $model->upload(); } } if ($model->ord == "") { $model->ord = 0; } if ($model->save()) { return $this->redirect(['view', 'id' => $model->id]); } } else { return $this->render('create', ['model' => $model]); } }
/** * Creates a new Ads model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Ads(); if ($model->load(Yii::$app->request->post())) { if (isset($_FILES) && $_FILES) { $model->imageFile = UploadedFile::getInstance($model, 'imageFile'); if ($model->imageFile) { $model->upload(); } } $model->start_time = strtotime($model->start_time); $model->end_time = strtotime($model->end_time); if ($model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { var_dump($model); } } return $this->render('create', ['model' => $model]); }