public function update($id)
    {
        /** @var FormRequest $request */
        $request = app($this->getUpdateRequestClass());
        $record  = $this->modelRepository->findOrFail($id);

        $data = $request->only($this->getRelevantFormFieldKeys());

        /** @var FormDataStorerInterface $storer */
        $storer = app(FormDataStorerInterface::class);
        $storer->setModelInformation($this->getModelInformation());

        if ( ! $storer->store($record, $data)) {
            // @codeCoverageIgnoreStart
            return redirect()->back()
                ->withInput()
                ->withErrors([
                    static::GENERAL_ERRORS_KEY => [ $this->getGeneralStoreFailureError() ],
                ]);
            // @codeCoverageIgnoreEnd
        }

        $this->storeActiveTab($request->input(static::ACTIVE_TAB_PANE_KEY));

        cms_flash(
            cms_trans(
                'models.store.success-message-edit',
                [ 'record' => $this->getSimpleRecordReference($id, $record) ]
            ),
            FlashLevel::SUCCESS
        );

        event( new Events\ModelUpdatedInCms($record) );

        if ($request->input(static::SAVE_AND_CLOSE_KEY)) {
            return redirect()->route("{$this->routePrefix}.index");
        }

        return redirect()->route("{$this->routePrefix}.edit", [ $record->getKey() ]);
    }
public function update($id)
    {
        /** @var FormRequest $request */
        $request = app($this->getUpdateRequestClass());
        $record  = $this->modelRepository->findOrFail($id);

        $data = $request->only($this->getRelevantFormFieldKeys());

        /** @var FormDataStorerInterface $storer */
        $storer = app(FormDataStorerInterface::class);
        $storer->setModelInformation($this->getModelInformation());

        if ( ! $storer->store($record, $data)) {
            // @codeCoverageIgnoreStart
            return redirect()->back()
                ->withInput()
                ->withErrors([
                    static::GENERAL_ERRORS_KEY => [ $this->getGeneralStoreFailureError() ],
                ]);
            // @codeCoverageIgnoreEnd
        }

        $this->storeActiveTab($request->input(static::ACTIVE_TAB_PANE_KEY));

        cms_flash(
            cms_trans(
                'models.store.success-message-edit',
                [ 'record' => $this->getSimpleRecordReference($id, $record) ]
            ),
            FlashLevel::SUCCESS
        );

        event( new Events\ModelUpdatedInCms($record) );

        if ($request->input(static::SAVE_AND_CLOSE_KEY)) {
            return redirect()->route("{$this->routePrefix}.index");
        }

        return redirect()->route("{$this->routePrefix}.edit", [ $record->getKey() ]);
    }
public function update ( $ id ) { /** @var FormRequest $request */ $ request = app ( $ this -> getUpdateRequestClass ( ) ) ; $ record = $ this -> modelRepository -> findOrFail ( $ id ) ; $ data = $ request -> only ( $ this -> getRelevantFormFieldKeys ( ) ) ; /** @var FormDataStorerInterface $storer */ $ storer = app ( FormDataStorerInterface :: class ) ; $ storer -> setModelInformation ( $ this -> getModelInformation ( ) ) ; if ( ! $ storer -> store ( $ record , $ data ) ) { // @codeCoverageIgnoreStart return redirect ( ) -> back ( ) -> withInput ( ) -> withErrors ( [ static :: GENERAL_ERRORS_KEY => [ $ this -> getGeneralStoreFailureError ( ) ] , ] ) ; // @codeCoverageIgnoreEnd } $ this -> storeActiveTab ( $ request -> input ( static :: ACTIVE_TAB_PANE_KEY ) ) ; cms_flash ( cms_trans ( 'models.store.success-message-edit' , [ 'record' => $ this -> getSimpleRecordReference ( $ id , $ record ) ] ) , FlashLevel :: SUCCESS ) ; event ( new Events \ ModelUpdatedInCms ( $ record ) ) ; if ( $ request -> input ( static :: SAVE_AND_CLOSE_KEY ) ) { return redirect ( ) -> route ( "{$this->routePrefix}.index" ) ; } return redirect ( ) -> route ( "{$this->routePrefix}.edit" , [ $ record -> getKey ( ) ] ) ; }
Processes a submitted for to edit an existing record.

@param mixed $id
@return mixed
@event ModelUpdatedInCms
Processes a submitted for to edit an existing record .