Created
January 19, 2017 01:13
-
-
Save noxify/f0ee130f6915e587c0bbfef0035f4636 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function update(LessonCrudRequest $request) | |
{ | |
$this->crud->hasAccessOrFail('update'); | |
// replace empty values with NULL, so that it will work with MySQL strict mode on | |
foreach ($request->input() as $key => $value) { | |
if (empty($value) && $value !== '0') { | |
$request->request->set($key, null); | |
} | |
} | |
// update the row in the db | |
$item = $this->crud->update($request->get($this->crud->model->getKeyName()), | |
$request->except('redirect_after_save', '_token', '_method', 'tags')); | |
$item->retag($request->input('tags')); | |
$this->data['entry'] = $this->crud->entry = $item; | |
// show a success message | |
\Alert::success(trans('backpack::crud.update_success'))->flash(); | |
// save the redirect choice for next time | |
$this->setSaveAction(); | |
return $this->performSaveAction(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment