public function update($id)
    {

        $model = ModuleRow::withoutGlobalScopes()->findOrFail($id);
        if (!request()->isMethod('put')) {
            $form = $this->form($model);
        } else {
            $input = Input::all();
            $user  = auth()->user();

            if (!$user->hasRoles('member')) {
                $model->user_id = array_get($input, 'user');
            }
            $model->name  = array_get($input, 'name');
            $model->value = array_only($input, ['field_1', 'field_2']);
            $form         = $this->form($model);

            if (!$form->isValid()) {
                return redirect_with_errors(handles('antares::sample_module/index/' . $id . '/edit'), $form->getMessageBag());
            }

            if (!$model->save()) {
                event('notifications.item_has_not_been_updated', ['variables' => ['user' => user(), 'item' => $model]]);
                return redirect_with_message(handles('antares::sample_module/index'), trans('antares/sample_module::messages.update_error'), 'error');
            }
            event('notifications.item_has_been_updated', ['variables' => ['user' => user(), 'item' => $model]]);

            return redirect_with_message(handles('antares::sample_module/index'), trans('antares/sample_module::messages.update_success'), 'success');
        }

        return view('antares/sample_module::admin.module.create', ['form' => $form]);
    }
public function update($id)
    {

        $model = ModuleRow::withoutGlobalScopes()->findOrFail($id);
        if (!request()->isMethod('put')) {
            $form = $this->form($model);
        } else {
            $input = Input::all();
            $user  = auth()->user();

            if (!$user->hasRoles('member')) {
                $model->user_id = array_get($input, 'user');
            }
            $model->name  = array_get($input, 'name');
            $model->value = array_only($input, ['field_1', 'field_2']);
            $form         = $this->form($model);

            if (!$form->isValid()) {
                return redirect_with_errors(handles('antares::sample_module/index/' . $id . '/edit'), $form->getMessageBag());
            }

            if (!$model->save()) {
                event('notifications.item_has_not_been_updated', ['variables' => ['user' => user(), 'item' => $model]]);
                return redirect_with_message(handles('antares::sample_module/index'), trans('antares/sample_module::messages.update_error'), 'error');
            }
            event('notifications.item_has_been_updated', ['variables' => ['user' => user(), 'item' => $model]]);

            return redirect_with_message(handles('antares::sample_module/index'), trans('antares/sample_module::messages.update_success'), 'success');
        }

        return view('antares/sample_module::admin.module.create', ['form' => $form]);
    }
public function update ( $ id ) { $ model = ModuleRow :: withoutGlobalScopes ( ) -> findOrFail ( $ id ) ; if ( ! request ( ) -> isMethod ( 'put' ) ) { $ form = $ this -> form ( $ model ) ; } else { $ input = Input :: all ( ) ; $ user = auth ( ) -> user ( ) ; if ( ! $ user -> hasRoles ( 'member' ) ) { $ model -> user_id = array_get ( $ input , 'user' ) ; } $ model -> name = array_get ( $ input , 'name' ) ; $ model -> value = array_only ( $ input , [ 'field_1' , 'field_2' ] ) ; $ form = $ this -> form ( $ model ) ; if ( ! $ form -> isValid ( ) ) { return redirect_with_errors ( handles ( 'antares::sample_module/index/' . $ id . '/edit' ) , $ form -> getMessageBag ( ) ) ; } if ( ! $ model -> save ( ) ) { event ( 'notifications.item_has_not_been_updated' , [ 'variables' => [ 'user' => user ( ) , 'item' => $ model ] ] ) ; return redirect_with_message ( handles ( 'antares::sample_module/index' ) , trans ( 'antares/sample_module::messages.update_error' ) , 'error' ) ; } event ( 'notifications.item_has_been_updated' , [ 'variables' => [ 'user' => user ( ) , 'item' => $ model ] ] ) ; return redirect_with_message ( handles ( 'antares::sample_module/index' ) , trans ( 'antares/sample_module::messages.update_success' ) , 'success' ) ; } return view ( 'antares/sample_module::admin.module.create' , [ 'form' => $ form ] ) ; }
When updates form fields in database

@param mixes $id
@return \Illuminate\Http\RedirectResponse
When updates form fields in database