mercredi 5 août 2015

Laravel 5.1 - How to use Model in Global function file


I created a common.php for my all the global function. When I run my first function {{Common::test()}}

It's working fine But I can not use model in it.

namespace App\library;
{
    class Common {

            public static function test()
            {
                echo "Yes";
                return "This comes from Common File";
            }
            public static function getCmsBlocks()
            {
                $model = Modelname::all();
                if($model){
                    echo "asdad";
                }else
                {
                    echo "sadasd";
                }
            }

    }
}

I don't get my output when I run {{Common::getCmsBlocks()}}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire