errorHandler( 404, fn() => 'whoops!' ); $router->add( 'GET', '/', [ShowDashboardController::class, 'handle'], )->name('show-dashboard'); // locations... $router->add( 'GET', '/locations', [ShowLocationsController::class, 'handle'], )->name('show-locations'); $router->add( 'GET', '/locations/create', [ShowCreateLocationFormController::class, 'handle'], )->name('show-create-location-form'); $router->add( 'POST', '/locations/create', [CreateLocationController::class, 'handle'], )->name('create-location'); $router->add( 'GET', '/locations/view/{location}', [ShowLocationController::class, 'handle'], )->name('view-location'); // items... $router->add( 'GET', '/items', [ShowItemsController::class, 'handle'], )->name('show-items'); $router->add( 'GET', '/items/create', [ShowCreateItemFormController::class, 'handle'], )->name('show-create-item-form'); $router->add( 'POST', '/items/create', [CreateItemController::class, 'handle'], )->name('create-item'); $router->add( 'GET', '/items/view/{item}', [ShowItemController::class, 'handle'], )->name('view-item'); // stock movements... // // note: each of these six paths uses a distinct literal segment // (receive-form/receive, withdraw-form/withdraw, adjust-form/adjust). // Framework\Routing\Route::matches() does not check the HTTP method // once it falls through to its parameterised-path regex, and matches // that regex unanchored — so a shorter dynamic route (like view-item // above) would otherwise swallow any longer path that starts with the // same segments (e.g. "/items/view/{item}/receive"), regardless of // method. Giving every dynamic route here its own unique path segment // sidesteps that rather than patching the router. $router->add( 'GET', '/items/receive-form/{item}', [ShowReceiveStockFormController::class, 'handle'], )->name('show-receive-stock-form'); $router->add( 'POST', '/items/receive/{item}', [ReceiveStockController::class, 'handle'], )->name('receive-stock'); $router->add( 'GET', '/items/withdraw-form/{item}', [ShowWithdrawStockFormController::class, 'handle'], )->name('show-withdraw-stock-form'); $router->add( 'POST', '/items/withdraw/{item}', [WithdrawStockController::class, 'handle'], )->name('withdraw-stock'); $router->add( 'GET', '/items/adjust-form/{item}', [ShowAdjustStockFormController::class, 'handle'], )->name('show-adjust-stock-form'); $router->add( 'POST', '/items/adjust/{item}', [AdjustStockController::class, 'handle'], )->name('adjust-stock'); // users... $router->add( 'GET', '/register', [ShowRegisterFormController::class, 'handle'], )->name('show-register-form'); $router->add( 'POST', '/register', [RegisterUserController::class, 'handle'], )->name('register-user'); $router->add( 'POST', '/log-in', [LogInUserController::class, 'handle'], )->name('log-in-user'); $router->add( 'GET', '/log-out', [LogOutUserController::class, 'handle'], )->name('log-out-user'); };