feat: ✨ Added API-Route support for extensions
This commit is contained in:
parent
30f70b35a2
commit
64cd6ac98c
6 changed files with 29 additions and 6 deletions
|
@ -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';
|
||||
|
|
21
routes/extensions_api.php
Normal file
21
routes/extensions_api.php
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::group(['prefix' => '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;
|
||||
}
|
||||
}
|
||||
});
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
|
@ -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';
|
||||
|
|
Loading…
Add table
Reference in a new issue