summaryrefslogtreecommitdiff
path: root/routes/web.php
blob: 8613ef7f6441418f22fe5f5a4fa4227cbd2798b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php

use Illuminate\Support\Facades\Route;

use Lightscale\ScormPlayer\Http\Controllers\ScormPlayerController;

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::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);
    $middleware = config('scorm.middleware');

    if(!empty($middleware)) {
        $route->middleware($middleware);
    }

    $route->group($group);

});