public function postCreateSection(Request $request)
 {
     $section = new Section();
     $section->title = $request->input('title');
     $section->slug = str_slug($request->input('title'), '-');
     $section->save();
     return redirect(route('getSections'))->with('messages', 'Section	 created.');
 }
Beispiel #2
0
 /**
  * Creates a new Section model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Section();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 /**
  * Creates a new Section model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Section();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         Yii::$app->session->setFlash('success', 'Saved successfully');
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 /**
  * Creates a new Section model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Section();
     $section_array = $this->getAllSection();
     $model->beforeSave(true);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model, 'section_array' => $section_array]);
     }
 }
 public function saveNewSectionRecord()
 {
     $section = new Section();
     $section['year_id'] = Input::get('drpYear');
     $section['description'] = Input::get('txtSection');
     if ($section->save()) {
         return 1;
     } else {
         return 0;
     }
 }
 /**
  * Creates a new Section model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Section();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         // data section
         $data_section = $_POST['Section'];
         // name catalog
         foreach ($data_section as $vlSection) {
             $name_section = $vlSection;
         }
         // last id catalog
         $last_section = Section::find()->orderBy('id_section DESC')->one();
         $last = $last_section->id_section;
         // insert search_table
         $search_section = new SearchTable(['name_search' => $name_section, 'type_search' => '2', 'link_search' => $last]);
         $search_section->save();
         return $this->redirect(['view', 'id' => $model->id_section]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }