Skip to content

Instantly share code, notes, and snippets.

@noxify
Created January 19, 2017 01:13
Show Gist options
  • Save noxify/f0ee130f6915e587c0bbfef0035f4636 to your computer and use it in GitHub Desktop.
Save noxify/f0ee130f6915e587c0bbfef0035f4636 to your computer and use it in GitHub Desktop.
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