Beispiel #1
0
 /**
  * Creates a new Slide model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Slide();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['index']);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 /**
  * Creates a new Slide model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Slide();
     $image = new FileUpload();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['update', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model, 'image' => $image]);
     }
 }
Beispiel #3
0
 public function postAdd(Request $request)
 {
     $data = '';
     $name = $request->input('name');
     $alt = $request->input('alt');
     $image = $request->input('images');
     if (isset($name) && !empty($name)) {
         $table = new Slide();
         $table->name = $name;
         $table->create_time = date("Y-m-d H:i:s");
         $table->images = $image;
         $table->alt = $alt;
         $table->status = 2;
         // 2 : không chọn , 1 là được chọn
         $rs = $table->save();
         $LastInsertId = $table->id;
         $data = ['id' => $LastInsertId, 'name' => $name, 'create_time' => date("Y-m-d H:i:s"), 'images' => $image, 'alt' => $alt, 'status' => 2];
         $this->message = 'Thêm thành công !';
     } else {
         $this->error = true;
         $this->error_message = 'Vui lòng nhập đầy đủ dữ liệu ';
     }
     return $this->ResponseData($data);
 }
 /**
  * @param integer $slider_id
  */
 public function actionNewSlide($slider_id)
 {
     Yii::$app->response->format = Response::FORMAT_JSON;
     $slider = $this->findModel($slider_id);
     $model = new Slide();
     $model->slider_id = $slider->id;
     $model->active = 0;
     $model->sort_order = count($slider->getSlides());
     $model->save();
     return $this->redirect(['update', 'id' => $slider_id]);
 }