diff --git a/src/Facades/Lodata.php b/src/Facades/Lodata.php index 260e299e2..cc557a4e7 100644 --- a/src/Facades/Lodata.php +++ b/src/Facades/Lodata.php @@ -55,6 +55,8 @@ * @method static string getOdcUrl(Identifier|string $set) Get the Office Data Connection URL of the provided entity set * @method static string getPbidsUrl() Get the PowerBI discovery URL of this service * @method static string getOpenApiUrl() Get the OpenAPI specification document URL of this service + * @method static void ignoreRoutes() Disable the automatic registration of the base routes + * @method static bool shouldIgnoreRoutes() Determine if routes should be ignored * @package Flat3\Lodata\Facades */ class Lodata extends Facade diff --git a/src/Model.php b/src/Model.php index 172dc31f4..2f7d3d4f5 100644 --- a/src/Model.php +++ b/src/Model.php @@ -45,6 +45,12 @@ class Model implements AnnotationInterface */ protected $entityContainer; + /** + * Determine if routes should be ignored + * @var true + */ + protected $registersRoutes; + public function __construct() { $this->model = new ObjectArray(); @@ -372,4 +378,22 @@ public function getOpenApiUrl(): string { return ServiceProvider::endpoint().'openapi.json'; } + + /** + * Disable the automatic registration of the base routes + * @return void + */ + public function ignoreRoutes(): void + { + $this->registersRoutes = false; + } + + /** + * Determine if routes should be ignored + * @return bool True if routes should be ignored, false otherwise. + */ + public function shouldIgnoreRoutes(): bool + { + return $this->registersRoutes; + } } diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index beb3b89d4..629674aed 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -81,6 +81,9 @@ public function boot() Route::get("{$route}/_lodata/odata.pbids", [PBIDS::class, 'get']); Route::get("{$route}/_lodata/{identifier}.odc", [ODCFF::class, 'get']); Route::resource("{$route}/_lodata/monitor", Monitor::class); - Route::any("{$route}{path}", [OData::class, 'handle'])->where('path', '(.*)')->middleware($middleware); + + if (Lodata::shouldIgnoreRoutes()) { + Route::any("{$route}{path}", [OData::class, 'handle'])->where('path', '(.*)')->middleware($middleware); + } } }