diff --git a/src/Facades/Lodata.php b/src/Facades/Lodata.php index fc32bfcab..573bf091e 100644 --- a/src/Facades/Lodata.php +++ b/src/Facades/Lodata.php @@ -13,6 +13,7 @@ use Flat3\Lodata\Interfaces\Operation\FunctionInterface; use Flat3\Lodata\Interfaces\ResourceInterface; use Flat3\Lodata\Interfaces\ServiceInterface; +use Flat3\Lodata\Model; use Flat3\Lodata\Operation; use Flat3\Lodata\Singleton; use Illuminate\Support\Facades\Facade; @@ -40,6 +41,6 @@ class Lodata extends Facade { protected static function getFacadeAccessor() { - return 'lodata.model'; + return Model::class; } } \ No newline at end of file diff --git a/src/Helper/Gate.php b/src/Helper/Gate.php index 74b5d25b7..791965fd2 100644 --- a/src/Helper/Gate.php +++ b/src/Helper/Gate.php @@ -55,7 +55,7 @@ public static function check( $gate->transaction = $transaction; $gate->arguments = $arguments; - if (ServiceProvider::usingPreview()) { + if (ServiceProvider::hasDisabledAuth()) { return; } diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index df3a1eee3..887ea3631 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -25,13 +25,17 @@ public function register() $this->mergeConfigFrom(__DIR__.'/../config.php', 'lodata'); } - public static function usingPreview(): bool + public static function hasDisabledAuth(): bool { - return env('LODATA_PREVIEW', false); + return env('LODATA_DISABLE_AUTH', false); } public function boot() { + if ($this->app->runningInConsole()) { + $this->publishes([__DIR__.'/../config.php' => config_path('lodata.php')], 'config'); + } + $this->app->singleton(Model::class, function () { return new Model(); }); @@ -42,7 +46,7 @@ public function boot() $middleware = config('lodata.middleware', []); - if (self::usingPreview()) { + if (self::hasDisabledAuth()) { $middleware = []; } diff --git a/tests/Unit/Protocol/PreviewTest.php b/tests/Unit/Protocol/PreviewTest.php index 5c6386f65..a8b06b8a1 100644 --- a/tests/Unit/Protocol/PreviewTest.php +++ b/tests/Unit/Protocol/PreviewTest.php @@ -10,7 +10,7 @@ class PreviewTest extends TestCase { public function setUp(): void { - Env::getRepository()->set('LODATA_PREVIEW', 1); + Env::getRepository()->set('LODATA_DISABLE_AUTH', 1); parent::setUp(); $this->gateMock->andReturnFalse(); $this->withFlightModel(); @@ -19,7 +19,7 @@ public function setUp(): void public function tearDown(): void { parent::tearDown(); - Env::getRepository()->clear('LODATA_PREVIEW'); + Env::getRepository()->clear('LODATA_DISABLE_AUTH'); } public function test_disables_auth()