close

非static參數使用方式為$this->參數名稱

ex: $this->aaa;

 

而static參數使用方式為self::$參數名稱

ex: self::$aaa;

--

That's because the Facade class only "redirects" method calls to the underlying class. So you can't access properties directly. The simplest solution is using a getter method.

 

class Facility
{
    public static $MODEL_NOT_FOUND = '-1';

    public function __construct() { ... }

    public function getModelNotFound(){
        return self::$MODEL_NOT_FOUND;
    }
}

 

The alternative would be to write your own Facade class that extends from Illuminate\Support\Facades\Facade and make use of magic methods to access properties directly

--

轉自 https://stackoverflow.com/questions/27347953/use-static-variables-in-laravel-facades

 

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 dizzy03 的頭像
    dizzy03

    碎碎念

    dizzy03 發表在 痞客邦 留言(0) 人氣()