本文整理汇总了PHP中app\models\Language::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Language::save方法的具体用法?PHP Language::save怎么用?PHP Language::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Language
的用法示例。
在下文中一共展示了Language::save方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCreate
/**
* 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: save
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: store
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);
}
}