protected static function findRevision($id, $language_id, $revision_id = null)
    {
        try {
            if (is_numeric($revision_id) && $revision_id != 0) {
                $revision = Revision::findOrFail($revision_id);

                if ($revision->content_id != $id) {
                    throw new RevisionEntityMismatchException("This revision doesn't belong to this entity");
                }

                if ($revision->language_id != $language_id) {
                    //TODO :: throw an exception in this case as well
                }

                return $revision;
            }

            return Revision::where('content_id', $id)
                ->where('language_id', $language_id)
                ->where('published', true)
                ->firstOrFail();
        } catch (ModelNotFoundException $e) {
            if (is_numeric($revision_id) && $revision_id != 0) {
                throw new RevisionNotFoundException("This revision doesn't exist", 0, $e);
            }

            $count = Revision::where('content_id', $id)->where('language_id', $language_id)->count();

            if ($count) {
                $message = "There are revisions in language_id='$language_id' for Entity '$id' but none is published";
                throw new NoPublishedRevisionForLanguageException($message, 0, $e);
            } else {
                $message = "There no revisions in language_id='$language_id' for Entity '$id' but none is published";
                throw new NoRevisionForLanguageException($message, 0, $e);
            }
        }
    }
protected static function findRevision($id, $language_id, $revision_id = null)
    {
        try {
            if (is_numeric($revision_id) && $revision_id != 0) {
                $revision = Revision::findOrFail($revision_id);

                if ($revision->content_id != $id) {
                    throw new RevisionEntityMismatchException("This revision doesn't belong to this entity");
                }

                if ($revision->language_id != $language_id) {
                    //TODO :: throw an exception in this case as well
                }

                return $revision;
            }

            return Revision::where('content_id', $id)
                ->where('language_id', $language_id)
                ->where('published', true)
                ->firstOrFail();
        } catch (ModelNotFoundException $e) {
            if (is_numeric($revision_id) && $revision_id != 0) {
                throw new RevisionNotFoundException("This revision doesn't exist", 0, $e);
            }

            $count = Revision::where('content_id', $id)->where('language_id', $language_id)->count();

            if ($count) {
                $message = "There are revisions in language_id='$language_id' for Entity '$id' but none is published";
                throw new NoPublishedRevisionForLanguageException($message, 0, $e);
            } else {
                $message = "There no revisions in language_id='$language_id' for Entity '$id' but none is published";
                throw new NoRevisionForLanguageException($message, 0, $e);
            }
        }
    }
protected static function findRevision ( $ id , $ language_id , $ revision_id = null ) { try { if ( is_numeric ( $ revision_id ) && $ revision_id != 0 ) { $ revision = Revision :: findOrFail ( $ revision_id ) ; if ( $ revision -> content_id != $ id ) { throw new RevisionEntityMismatchException ( "This revision doesn't belong to this entity" ) ; } if ( $ revision -> language_id != $ language_id ) { //TODO :: throw an exception in this case as well } return $ revision ; } return Revision :: where ( 'content_id' , $ id ) -> where ( 'language_id' , $ language_id ) -> where ( 'published' , true ) -> firstOrFail ( ) ; } catch ( ModelNotFoundException $ e ) { if ( is_numeric ( $ revision_id ) && $ revision_id != 0 ) { throw new RevisionNotFoundException ( "This revision doesn't exist" , 0 , $ e ) ; } $ count = Revision :: where ( 'content_id' , $ id ) -> where ( 'language_id' , $ language_id ) -> count ( ) ; if ( $ count ) { $ message = "There are revisions in language_id='$language_id' for Entity '$id' but none is published" ; throw new NoPublishedRevisionForLanguageException ( $ message , 0 , $ e ) ; } else { $ message = "There no revisions in language_id='$language_id' for Entity '$id' but none is published" ; throw new NoRevisionForLanguageException ( $ message , 0 , $ e ) ; } } }
Find the requested Revision.

If a revision_id it will be requested against the requested ID and Language.

If none is requested, it will find the revision that is published in that language.

@param int $id The content ID
@param int $language_id The language ID
@param int $revision_id The revision ID which you want to load, this is optional
@throws NoPublishedRevisionForLanguageException
@throws NoRevisionForLanguageException
@throws RevisionEntityMismatchException
@throws RevisionNotFoundException
@return Revision
Find the requested Revision .