From b602d6dbe1ad1a8507f09a4924d8a9ef4903a17e Mon Sep 17 00:00:00 2001 From: Sam Light Date: Tue, 6 Sep 2022 12:43:08 +0100 Subject: Made all the routes configable --- config/scorm-player.php | 5 +++++ routes/web.php | 24 +++++++++++++++--------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/config/scorm-player.php b/config/scorm-player.php index 74f89fa..95f2a5f 100644 --- a/config/scorm-player.php +++ b/config/scorm-player.php @@ -1,5 +1,10 @@ '', + 'route_prefix_scorm' => 'scorm', + 'route_prefix_player' => 'player', + 'route_prefix_files' => 'files', + 'middleware_group' => 'web', 'middleware' => '', ]; diff --git a/routes/web.php b/routes/web.php index 4570f11..8613ef7 100644 --- a/routes/web.php +++ b/routes/web.php @@ -2,23 +2,29 @@ use Illuminate\Support\Facades\Route; -//use Illuminate\Routing\Middleware\SubstituteBindings; - use Lightscale\ScormPlayer\Http\Controllers\ScormPlayerController; -Route::name('scorm-player.')->prefix('elearning')->middleware([ - 'web', +Route::name('scorm-player.')->prefix(config('scorm.route_prefix'))->middleware([ + config('scorm.middleware_group', 'web'), ])->group(function() { Route::get('scorm-player-{version}.js', [ScormPlayerController::class, 'jsSource']) ->name('javascript'); $group = function() { - Route::get('/scorm/{sco}', 'scormLoad')->name('scorm.load'); - Route::post('/scorm/{tracking}', 'scormCommit')->name('scorm.commit'); - - Route::get('{module:uuid}', 'player')->name('player'); - Route::get('files/{uuid}/{path}', 'serveModule')->name('serve')->where('path', '.*'); + Route::prefix(config('scorm.route_prefix_scorm'))->group(function() { + Route::get('{sco}', 'scormLoad')->name('scorm.load'); + Route::post('{tracking}', 'scormCommit')->name('scorm.commit'); + }); + + Route::prefix(config('scorm.route_prefix_player')) + ->get('{module:uuid}', 'player') + ->name('player'); + + Route::prefix(config('scorm.route_prefix_files')) + ->get('{uuid}/{path}', 'serveModule') + ->where('path', '.*') + ->name('serve'); }; $route = Route::controller(ScormPlayerController::class); -- cgit v1.2.3