<?php

use App\Http\Controllers\Api\EsgController;
use App\Http\Controllers\Api\NewsController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "api" middleware group. Make something great!
|
*/

Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
    return $request->user();
});
Route::prefix('{locale}')->group(function (){
    Route::prefix('news')->group(function (){
        Route::get('/', [NewsController::class, 'getTop']);
        Route::get('/list', [NewsController::class, 'list']);
        Route::get('/detail/{id}', [NewsController::class, 'detail'])->whereIn('locale', ["tw", "en", "jp"])->where('id', '[0-9]+');
    });
    Route::prefix('esg')->group(function () {
        Route::get('/', [EsgController::class, "main"]);
        Route::get('/{key}', [EsgController::class, "esgContent"]);
    });
})->whereIn('locale', ["tw", "en"]);

