Facade (この場合はシングルトン) があり、次を使用して登録しますServiceProvider
。
サービスプロバイダー
use App;
class FacilityServiceProvider extends ServiceProvider
{
public function register()
{
$this->app->singleton('Facility', function(){
return new Facility();
});
// Shortcut so developers don't need to add an Alias in app/config/app.php
$this->app->booting(function()
{
$loader = \Illuminate\Foundation\AliasLoader::getInstance();
$loader->alias('Facility', 'CLG\Facility\Facades\FacilityFacade');
});
}
}
ファサード
use Illuminate\Support\Facades\Facade;
class FacilityFacade extends Facade {
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor() { return 'Facility'; }
}
今、私は自分のFacility
クラス内に静的変数を持ちたいと思っています:
ファシリティ.php
class Facility
{
public static $MODEL_NOT_FOUND = '-1';
public function __construct() { ... }
}
しかし、 を使用するFacility::$MODEL_NOT_FOUND
と、 が得られAccess to undeclared static property
ます。
私は何を間違っていますか?