src/GetArticleFromDataBase.php
public static function get($nickname) {
        try {
            $lang = App::getLocale();
            $modelClass = config('sirgrimorum.transarticles.default_articles_model');
            $langColumn = config('sirgrimorum.transarticles.default_lang_column');
            $findArticle = config('sirgrimorum.transarticles.default_findarticle_function_name');
            $article = $modelClass::{$findArticle}($nickname)->where($langColumn, "=", $lang)->first();
            if ($article) {
                return $article->content;
            } else {
                $article = $modelClass::{$findArticle}($nickname)->first();
                if ($article) {
                    return $article->content . "<small><span class='label label-warning'>" . $article->{$langColumn} . "</span></small>";
                } else {
                    return $nickname;
                }
            }
        } catch (Exception $ex) {
            return $nickname . "<pre class='label label-warning'>" . print_r([$ex->getMessage(), $ex->getTraceAsString()], true) . "</pre>";
        }
    }
public static function get($nickname) {
        try {
            $lang = App::getLocale();
            $modelClass = config('sirgrimorum.transarticles.default_articles_model');
            $langColumn = config('sirgrimorum.transarticles.default_lang_column');
            $findArticle = config('sirgrimorum.transarticles.default_findarticle_function_name');
            $article = $modelClass::{$findArticle}($nickname)->where($langColumn, "=", $lang)->first();
            if ($article) {
                return $article->content;
            } else {
                $article = $modelClass::{$findArticle}($nickname)->first();
                if ($article) {
                    return $article->content . "<small><span class='label label-warning'>" . $article->{$langColumn} . "</span></small>";
                } else {
                    return $nickname;
                }
            }
        } catch (Exception $ex) {
            return $nickname . "<pre class='label label-warning'>" . print_r([$ex->getMessage(), $ex->getTraceAsString()], true) . "</pre>";
        }
    }
public static function get ( $ nickname ) { try { $ lang = App :: getLocale ( ) ; $ modelClass = config ( 'sirgrimorum.transarticles.default_articles_model' ) ; $ langColumn = config ( 'sirgrimorum.transarticles.default_lang_column' ) ; $ findArticle = config ( 'sirgrimorum.transarticles.default_findarticle_function_name' ) ; $ article = $ modelClass :: { $ findArticle } ( $ nickname ) -> where ( $ langColumn , "=" , $ lang ) -> first ( ) ; if ( $ article ) { return $ article -> content ; } else { $ article = $ modelClass :: { $ findArticle } ( $ nickname ) -> first ( ) ; if ( $ article ) { return $ article -> content . "<small><span class='label label-warning'>" . $ article -> { $ langColumn } . "</span></small>" ; } else { return $ nickname ; } } } catch ( Exception $ ex ) { return $ nickname . "<pre class='label label-warning'>" . print_r ( [ $ ex -> getMessage ( ) , $ ex -> getTraceAsString ( ) ] , true ) . "</pre>" ; } }
Return the translation for the article
@param String $nickname The article to load using dot notation
@return String The content of the article localized, if not found, return the first article in a diferent language, if neither, returns de $nickname
Return the translation for the article