api.php 1008B

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