public function rollback($entity, $id)
    {
        $modelString = str_replace('_', '\\', $entity);

        if (!class_exists($modelString)) {
            Cms::notification('Could not rollback Model not found', 'warning');

            return redirect(URL::previous());
        }

        $model = app($modelString);
        $modelInstance = $model->find($id);

        $archive = Archive::where('entity_id', $id)->where('entity_type', $modelString)->limit(1)->offset(1)->orderBy('id', 'desc')->first();

        if (!$archive) {
            Cms::notification('Could not rollback', 'warning');

            return redirect(URL::previous());
        }

        $archiveData = (array) json_decode($archive->entity_data);

        $modelInstance->fill($archiveData);
        $modelInstance->save();

        Cms::notification('Rollback was successful', 'success');

        return redirect(URL::previous());
    }
public function rollback($entity, $id)
    {
        $modelString = str_replace('_', '\\', $entity);

        if (!class_exists($modelString)) {
            Cms::notification('Could not rollback Model not found', 'warning');

            return redirect(URL::previous());
        }

        $model = app($modelString);
        $modelInstance = $model->find($id);

        $archive = Archive::where('entity_id', $id)->where('entity_type', $modelString)->limit(1)->offset(1)->orderBy('id', 'desc')->first();

        if (!$archive) {
            Cms::notification('Could not rollback', 'warning');

            return redirect(URL::previous());
        }

        $archiveData = (array) json_decode($archive->entity_data);

        $modelInstance->fill($archiveData);
        $modelInstance->save();

        Cms::notification('Rollback was successful', 'success');

        return redirect(URL::previous());
    }
public function rollback ( $ entity , $ id ) { $ modelString = str_replace ( '_' , '\\' , $ entity ) ; if ( ! class_exists ( $ modelString ) ) { Cms :: notification ( 'Could not rollback Model not found' , 'warning' ) ; return redirect ( URL :: previous ( ) ) ; } $ model = app ( $ modelString ) ; $ modelInstance = $ model -> find ( $ id ) ; $ archive = Archive :: where ( 'entity_id' , $ id ) -> where ( 'entity_type' , $ modelString ) -> limit ( 1 ) -> offset ( 1 ) -> orderBy ( 'id' , 'desc' ) -> first ( ) ; if ( ! $ archive ) { Cms :: notification ( 'Could not rollback' , 'warning' ) ; return redirect ( URL :: previous ( ) ) ; } $ archiveData = ( array ) json_decode ( $ archive -> entity_data ) ; $ modelInstance -> fill ( $ archiveData ) ; $ modelInstance -> save ( ) ; Cms :: notification ( 'Rollback was successful' , 'success' ) ; return redirect ( URL :: previous ( ) ) ; }
Rollback to a previous version of an entity.

@param string $entity
@param int    $id

@return Redirect
Rollback to a previous version of an entity .