/** * Creates a new About model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new About(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
public function index() { $abouts = About::all(); $about = new About(); if (Request::isMethod('post')) { $validator = Validator::make(Request::all(), $this->rules); if ($validator->passes()) { $about->title = Request::input('title'); $about->titleEng = Request::input('titleEng'); $about->text = Request::input('text'); $about->textEng = Request::input('textEng'); $about->enabled = Request::has('enabled'); $about->save(); return redirect('admin/about')->with('msg', 'Текст о компании был успешно создан'); } else { return redirect('admin/about')->withInput()->withErrors($validator); } } return view('admin.about', ['about' => $about, 'abouts' => $abouts]); }