25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

142 satır
4.5KB

  1. <?php
  2. use App\Http\Controllers\ShowDashboardController;
  3. use App\Http\Controllers\Locations\CreateLocationController;
  4. use App\Http\Controllers\Locations\ShowCreateLocationFormController;
  5. use App\Http\Controllers\Locations\ShowLocationController;
  6. use App\Http\Controllers\Locations\ShowLocationsController;
  7. use App\Http\Controllers\Items\AdjustStockController;
  8. use App\Http\Controllers\Items\CreateItemController;
  9. use App\Http\Controllers\Items\ReceiveStockController;
  10. use App\Http\Controllers\Items\ShowAdjustStockFormController;
  11. use App\Http\Controllers\Items\ShowCreateItemFormController;
  12. use App\Http\Controllers\Items\ShowItemController;
  13. use App\Http\Controllers\Items\ShowItemsController;
  14. use App\Http\Controllers\Items\ShowReceiveStockFormController;
  15. use App\Http\Controllers\Items\ShowWithdrawStockFormController;
  16. use App\Http\Controllers\Items\WithdrawStockController;
  17. use App\Http\Controllers\Users\LogInUserController;
  18. use App\Http\Controllers\Users\LogOutUserController;
  19. use App\Http\Controllers\Users\RegisterUserController;
  20. use App\Http\Controllers\Users\ShowRegisterFormController;
  21. use Framework\Routing\Router;
  22. return function(Router $router) {
  23. $router->errorHandler(
  24. 404, fn() => 'whoops!'
  25. );
  26. $router->add(
  27. 'GET', '/',
  28. [ShowDashboardController::class, 'handle'],
  29. )->name('show-dashboard');
  30. // locations...
  31. $router->add(
  32. 'GET', '/locations',
  33. [ShowLocationsController::class, 'handle'],
  34. )->name('show-locations');
  35. $router->add(
  36. 'GET', '/locations/create',
  37. [ShowCreateLocationFormController::class, 'handle'],
  38. )->name('show-create-location-form');
  39. $router->add(
  40. 'POST', '/locations/create',
  41. [CreateLocationController::class, 'handle'],
  42. )->name('create-location');
  43. $router->add(
  44. 'GET', '/locations/view/{location}',
  45. [ShowLocationController::class, 'handle'],
  46. )->name('view-location');
  47. // items...
  48. $router->add(
  49. 'GET', '/items',
  50. [ShowItemsController::class, 'handle'],
  51. )->name('show-items');
  52. $router->add(
  53. 'GET', '/items/create',
  54. [ShowCreateItemFormController::class, 'handle'],
  55. )->name('show-create-item-form');
  56. $router->add(
  57. 'POST', '/items/create',
  58. [CreateItemController::class, 'handle'],
  59. )->name('create-item');
  60. $router->add(
  61. 'GET', '/items/view/{item}',
  62. [ShowItemController::class, 'handle'],
  63. )->name('view-item');
  64. // stock movements...
  65. //
  66. // note: each of these six paths uses a distinct literal segment
  67. // (receive-form/receive, withdraw-form/withdraw, adjust-form/adjust).
  68. // Framework\Routing\Route::matches() does not check the HTTP method
  69. // once it falls through to its parameterised-path regex, and matches
  70. // that regex unanchored — so a shorter dynamic route (like view-item
  71. // above) would otherwise swallow any longer path that starts with the
  72. // same segments (e.g. "/items/view/{item}/receive"), regardless of
  73. // method. Giving every dynamic route here its own unique path segment
  74. // sidesteps that rather than patching the router.
  75. $router->add(
  76. 'GET', '/items/receive-form/{item}',
  77. [ShowReceiveStockFormController::class, 'handle'],
  78. )->name('show-receive-stock-form');
  79. $router->add(
  80. 'POST', '/items/receive/{item}',
  81. [ReceiveStockController::class, 'handle'],
  82. )->name('receive-stock');
  83. $router->add(
  84. 'GET', '/items/withdraw-form/{item}',
  85. [ShowWithdrawStockFormController::class, 'handle'],
  86. )->name('show-withdraw-stock-form');
  87. $router->add(
  88. 'POST', '/items/withdraw/{item}',
  89. [WithdrawStockController::class, 'handle'],
  90. )->name('withdraw-stock');
  91. $router->add(
  92. 'GET', '/items/adjust-form/{item}',
  93. [ShowAdjustStockFormController::class, 'handle'],
  94. )->name('show-adjust-stock-form');
  95. $router->add(
  96. 'POST', '/items/adjust/{item}',
  97. [AdjustStockController::class, 'handle'],
  98. )->name('adjust-stock');
  99. // users...
  100. $router->add(
  101. 'GET', '/register',
  102. [ShowRegisterFormController::class, 'handle'],
  103. )->name('show-register-form');
  104. $router->add(
  105. 'POST', '/register',
  106. [RegisterUserController::class, 'handle'],
  107. )->name('register-user');
  108. $router->add(
  109. 'POST', '/log-in',
  110. [LogInUserController::class, 'handle'],
  111. )->name('log-in-user');
  112. $router->add(
  113. 'GET', '/log-out',
  114. [LogOutUserController::class, 'handle'],
  115. )->name('log-out-user');
  116. };

Powered by TurnKey Linux.