src/GetArticleFromDataBase.php
public static function getjs($scope, $basevar = '') {
        if ($basevar == '') {
            $basevar = config('sirgrimorum.transarticles.default_base_var');
        }
        $lang = App::getLocale();
        $listo = false;
        try {
            $modelClass = config('sirgrimorum.transarticles.default_articles_model');
            $langColumn = config('sirgrimorum.transarticles.default_lang_column');
            $findArticles = config('sirgrimorum.transarticles.default_findarticles_function_name');
            $findArticle = config('sirgrimorum.transarticles.default_findarticle_function_name');
            $articles = $modelClass::{$findArticles}($scope)->where($langColumn, "=", $lang)->get();
            if ($articles) {
                $listo = true;
            } else {
                $articles = $modelClass::{$findArticles}($scope)->get();
                if ($articles) {
                    $listo = true;
                } else {
                    $articles = $modelClass::{$findArticle}($scope)->where($langColumn, "=", $lang)->first();
                    $listo = false;
                    if ($articles) {
                        $jsarray = [];
                        data_fill($jsarray, $scope, $articles->content);
                    } else {
                        $articles = $modelClass::{$findArticle}($scope)->first();
                        if ($articles) {
                            $jsarray = [];
                            data_fill($jsarray, $scope, $articles->content);
                            //$jsarray = $articles->content;
                        } else {
                            $jsarray = [];
                            data_fill($jsarray, $scope, $scope);
                        }
                    }
                }
            }
        } catch (Exception $ex) {
            return $scope . " - Error:" . print_r($ex->getMessage(), true);
        }
        if ($listo) {
            if ($articles) {
                $trans = [];
                foreach ($articles as $article) {
                    $trans[$article->nickname] = $article->content;
                }
                $jsarray = json_encode($trans);
                return "<script>window.{$basevar} = window.{$basevar} || {};{$basevar}.{$scope} = {$jsarray};</script>";
            } else {
                $jsarray = [];
                data_fill($jsarray, $scope, $scope);
            }
        } 
        $jsarray = json_encode($jsarray);
        return "<script>window.{$basevar} = window.{$basevar} || {};{$basevar} = {$jsarray};</script>";
    }
public static function getjs($scope, $basevar = '') {
        if ($basevar == '') {
            $basevar = config('sirgrimorum.transarticles.default_base_var');
        }
        $lang = App::getLocale();
        $listo = false;
        try {
            $modelClass = config('sirgrimorum.transarticles.default_articles_model');
            $langColumn = config('sirgrimorum.transarticles.default_lang_column');
            $findArticles = config('sirgrimorum.transarticles.default_findarticles_function_name');
            $findArticle = config('sirgrimorum.transarticles.default_findarticle_function_name');
            $articles = $modelClass::{$findArticles}($scope)->where($langColumn, "=", $lang)->get();
            if ($articles) {
                $listo = true;
            } else {
                $articles = $modelClass::{$findArticles}($scope)->get();
                if ($articles) {
                    $listo = true;
                } else {
                    $articles = $modelClass::{$findArticle}($scope)->where($langColumn, "=", $lang)->first();
                    $listo = false;
                    if ($articles) {
                        $jsarray = [];
                        data_fill($jsarray, $scope, $articles->content);
                    } else {
                        $articles = $modelClass::{$findArticle}($scope)->first();
                        if ($articles) {
                            $jsarray = [];
                            data_fill($jsarray, $scope, $articles->content);
                            //$jsarray = $articles->content;
                        } else {
                            $jsarray = [];
                            data_fill($jsarray, $scope, $scope);
                        }
                    }
                }
            }
        } catch (Exception $ex) {
            return $scope . " - Error:" . print_r($ex->getMessage(), true);
        }
        if ($listo) {
            if ($articles) {
                $trans = [];
                foreach ($articles as $article) {
                    $trans[$article->nickname] = $article->content;
                }
                $jsarray = json_encode($trans);
                return "<script>window.{$basevar} = window.{$basevar} || {};{$basevar}.{$scope} = {$jsarray};</script>";
            } else {
                $jsarray = [];
                data_fill($jsarray, $scope, $scope);
            }
        } 
        $jsarray = json_encode($jsarray);
        return "<script>window.{$basevar} = window.{$basevar} || {};{$basevar} = {$jsarray};</script>";
    }
public static function getjs ( $ scope , $ basevar = '' ) { if ( $ basevar == '' ) { $ basevar = config ( 'sirgrimorum.transarticles.default_base_var' ) ; } $ lang = App :: getLocale ( ) ; $ listo = false ; try { $ modelClass = config ( 'sirgrimorum.transarticles.default_articles_model' ) ; $ langColumn = config ( 'sirgrimorum.transarticles.default_lang_column' ) ; $ findArticles = config ( 'sirgrimorum.transarticles.default_findarticles_function_name' ) ; $ findArticle = config ( 'sirgrimorum.transarticles.default_findarticle_function_name' ) ; $ articles = $ modelClass :: { $ findArticles } ( $ scope ) -> where ( $ langColumn , "=" , $ lang ) -> get ( ) ; if ( $ articles ) { $ listo = true ; } else { $ articles = $ modelClass :: { $ findArticles } ( $ scope ) -> get ( ) ; if ( $ articles ) { $ listo = true ; } else { $ articles = $ modelClass :: { $ findArticle } ( $ scope ) -> where ( $ langColumn , "=" , $ lang ) -> first ( ) ; $ listo = false ; if ( $ articles ) { $ jsarray = [ ] ; data_fill ( $ jsarray , $ scope , $ articles -> content ) ; } else { $ articles = $ modelClass :: { $ findArticle } ( $ scope ) -> first ( ) ; if ( $ articles ) { $ jsarray = [ ] ; data_fill ( $ jsarray , $ scope , $ articles -> content ) ; //$jsarray = $articles->content; } else { $ jsarray = [ ] ; data_fill ( $ jsarray , $ scope , $ scope ) ; } } } } } catch ( Exception $ ex ) { return $ scope . " - Error:" . print_r ( $ ex -> getMessage ( ) , true ) ; } if ( $ listo ) { if ( $ articles ) { $ trans = [ ] ; foreach ( $ articles as $ article ) { $ trans [ $ article -> nickname ] = $ article -> content ; } $ jsarray = json_encode ( $ trans ) ; return "<script>window.{$basevar} = window.{$basevar} || {};{$basevar}.{$scope} = {$jsarray};</script>" ; } else { $ jsarray = [ ] ; data_fill ( $ jsarray , $ scope , $ scope ) ; } } $ jsarray = json_encode ( $ jsarray ) ; return "<script>window.{$basevar} = window.{$basevar} || {};{$basevar} = {$jsarray};</script>" ; }
return the JavaScript from article table


@param String $scope The scope to load
return the JavaScript from article table