<?php
// 取得user列表
Route::get('user', 'UserController@getUsers');
// 取得user
Route::get('user/{id}', 'UserController@getUser');
// 修改user
Route::put('user/{id}', 'UserController@updateUser');
// 刪除user
Route::delete('user/{id}', 'UserController@deleteUser');
// 或是大雜燴
Route::resource('user', UserController::class);
<?php
namespace App\Http\Controllers;
class UserController extends Controller
{
public function index()
{
}
public function show($id)
{
}
public function update($id)
{
}
public function destroy($id)
{
}
public function store()
{
}
}
<?php
Route::resource('user', UserController::class, ['only' => 'store'])