路由 (Route)

路由 (Route)

app/routes.php

Route::get('/', function () {
    return view('welcome');
});
php artisan route:list

路由動詞

Route::get('/', function(){});
Route::post('/', function(){});
Route::put('/', function(){});
Route::delete('/', function(){});

Route::any('/', function(){});

Route::match(['get', 'post'], '/', function(){});

練習題:建立 article 的 CRUD

路由參數

Route::get('/users/{id}', function($id){
  return 'this is user id: ' . $id;
});
Route::get('users/{name?}', function ($name = null) {
    return $name;
});

Route::get('users/{name?}', function ($name = 'alincode') {
    return $name;
});

API Route

Route::middleware('api')->get('/user', 'UserController@index');

  • Route 登入驗證

results for ""

    No results matching ""