/** * Update the specified resource in the database. * * @param int $id * @return Response */ public function update(UpdateRequest $request = null) { // if edit_permission is false, abort if (isset($this->crud['edit_permission']) && !$this->crud['edit_permission']) { abort(403, 'Not allowed.'); } $model = $this->crud['model']; $this->prepareFields($model::find(\Request::input('id'))); $all_variables = \Request::all(); // if the change_password field has been filled, change the password if ($all_variables['change_password'] != '') { $all_variables['password'] = $all_variables['change_password']; } $item = $model::find(\Request::input('id'))->update(parent::compactFakeFields($all_variables)); // if it's a relationship with a pivot table, also sync that foreach ($this->crud['fields'] as $k => $field) { if (isset($field['pivot']) && $field['pivot'] == true) { $model::find(\Request::input('id'))->{$field}['name']()->sync(\Request::input($field['name'])); } } // show a success message \Alert::success(trans('crud.update_success'))->flash(); return \Redirect::to($this->crud['route']); }
public function update(UpdateRequest $request) { return parent::updateCrud(); }
public function update(UpdateRequest $request) { $this->useTemplate(\Request::input('template')); return parent::updateCrud(); }