Example #1
0
 /**
  * Updates the specified item in storage.
  *
  * @param string $model Model to use.
  * @param int $id Item ID.
  * @return \Illuminate\Http\Response
  */
 public function update($model, $id)
 {
     $this->setModel($model);
     $this->checkAction('edit');
     $item = $this->staticModelFind($id);
     if (!$item) {
         abort(404);
     }
     $form = $this->staticModelGetForm();
     if (!$form->isValid()) {
         $this->session->reflash();
         return back()->withErrors($form->getErrors())->withInput()->with('msg', trans('lavanda::common.error_update'))->with('msg-type', 'danger');
     }
     $item->saveWithRelations($this->request->all());
     $redirectUrl = $this->session->get('back_url') ? $this->session->get('back_url') : $this->getRoute('index');
     return redirect()->to($redirectUrl)->with('msg', trans('lavanda::common.success_update'));
 }