api.php 1.2KB

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. use App\Http\Controllers\Api\EsgController;
  3. use App\Http\Controllers\Api\NewsController;
  4. use Illuminate\Http\Request;
  5. use Illuminate\Support\Facades\Route;
  6. /*
  7. |--------------------------------------------------------------------------
  8. | API Routes
  9. |--------------------------------------------------------------------------
  10. |
  11. | Here is where you can register API routes for your application. These
  12. | routes are loaded by the RouteServiceProvider and all of them will
  13. | be assigned to the "api" middleware group. Make something great!
  14. |
  15. */
  16. Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
  17. return $request->user();
  18. });
  19. Route::prefix('{locale}')->group(function (){
  20. Route::prefix('news')->group(function (){
  21. Route::get('/', [NewsController::class, 'getTop']);
  22. Route::get('/list', [NewsController::class, 'list']);
  23. Route::get('/detail/{id}', [NewsController::class, 'detail'])->whereIn('locale', ["tw", "en", "jp"])->where('id', '[0-9]+');
  24. });
  25. Route::prefix('esg')->group(function () {
  26. Route::get('/', [EsgController::class, "main"]);
  27. Route::get('/{key}', [EsgController::class, "esgContent"]);
  28. });
  29. })->whereIn('locale', ["tw", "en"]);