コード例 #1
0
 /**
  * Creates a new Language model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Language();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->l_id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
コード例 #2
0
 public function save($request)
 {
     //var_dump($request->input::all());
     $language = new Language();
     // $language->language = $request->input('language');
     // $language->symbol = $request->input('code');
     $language->language = 'English';
     $language->code = '01';
     if ($language->save()) {
         return $language->id;
     } else {
         return false;
     }
 }
コード例 #3
0
 public function store(UserFormRequest $request)
 {
     $validator = Validator::make($request->all(), $request->rules());
     if ($validator->fails()) {
         return redirect('create')->withErrors($validator)->withInput();
     } else {
         if (\Input::has('language_id')) {
             $id = \Input::get('language_id');
             $language = LanguageModel::find($id);
             $alert['msg'] = 'Language has been updated successfully';
         } else {
             $language = new LanguageModel();
             $alert['msg'] = 'Language has been created successfully';
         }
         $language->language = \Input::get('language');
         $language->code = \Input::get('code');
         $language->save();
         $alert['type'] = 'success';
         return Redirect::route('language')->with('alert', $alert);
     }
 }