diff --git a/app/Extensions/PaymentGateways/PayPal/routes.php b/app/Extensions/PaymentGateways/PayPal/web_routes.php similarity index 100% rename from app/Extensions/PaymentGateways/PayPal/routes.php rename to app/Extensions/PaymentGateways/PayPal/web_routes.php diff --git a/app/Extensions/PaymentGateways/Stripe/routes.php b/app/Extensions/PaymentGateways/Stripe/web_routes.php similarity index 100% rename from app/Extensions/PaymentGateways/Stripe/routes.php rename to app/Extensions/PaymentGateways/Stripe/web_routes.php diff --git a/routes/api.php b/routes/api.php index 0de04de6..74333b74 100644 --- a/routes/api.php +++ b/routes/api.php @@ -34,6 +34,8 @@ Route::middleware('api.token')->group(function () { Route::get('/notifications/{user}', [NotificationController::class, 'index']); Route::get('/notifications/{user}/{notification}', [NotificationController::class, 'view']); Route::post('/notifications', [NotificationController::class, 'send']); - Route::delete('/notifications/{user}', [NotificationController::class, 'delete']); Route::delete('/notifications/{user}/{notification}', [NotificationController::class, 'deleteOne']); + Route::delete('/notifications/{user}', [NotificationController::class, 'delete']); }); + +require __DIR__ . '/extensions_api.php'; diff --git a/routes/extensions_api.php b/routes/extensions_api.php new file mode 100644 index 00000000..31fb89d3 --- /dev/null +++ b/routes/extensions_api.php @@ -0,0 +1,21 @@ + 'extensions', 'middleware' => 'api.token'], function () { + // get all extensions that are inside App/Extensions + // It is important that the extensions are inside a folder with the name of the extension + // while those folders are inside Folders with the name of the type of extension like PaymentGateways, Themes, etc. + $extensionNamespaces = glob(app_path() . '/Extensions/*', GLOB_ONLYDIR); + $extensions = []; + foreach ($extensionNamespaces as $extensionNamespace) { + $extensions = array_merge($extensions, glob($extensionNamespace . '/*', GLOB_ONLYDIR)); + } + + foreach ($extensions as $extension) { + $routesFile = $extension . '/api_routes.php'; + if (file_exists($routesFile)) { + include_once $routesFile; + } + } +}); diff --git a/routes/extensions.php b/routes/extensions_web.php similarity index 91% rename from routes/extensions.php rename to routes/extensions_web.php index a08b309b..920dc299 100644 --- a/routes/extensions.php +++ b/routes/extensions_web.php @@ -3,7 +3,7 @@ use Illuminate\Support\Facades\Route; Route::group(['prefix' => 'extensions'], function () { - + // get all extensions that are inside App/Extensions // It is important that the extensions are inside a folder with the name of the extension // while those folders are inside Folders with the name of the type of extension like PaymentGateways, Themes, etc. @@ -14,9 +14,9 @@ Route::group(['prefix' => 'extensions'], function () { } foreach ($extensions as $extension) { - $routesFile = $extension . '/routes.php'; + $routesFile = $extension . '/web_routes.php'; if (file_exists($routesFile)) { include_once $routesFile; } - } -}); \ No newline at end of file + } +}); diff --git a/routes/web.php b/routes/web.php index 709bfff7..9c873ad1 100644 --- a/routes/web.php +++ b/routes/web.php @@ -216,4 +216,4 @@ Route::middleware(['auth', 'checkSuspended'])->group(function () { Route::get('/home', [HomeController::class, 'index'])->name('home'); }); -require __DIR__ . '/extensions.php'; +require __DIR__ . '/extensions_web.php';