在route目录下的api下编写restful协议的路由地址,默认地址为127.0.0.1:8000/api/people
use App\Http\Controllers\PeopleController;
Route::resource('people', PeopleController::class);
前端调用可以参照以下规则
调用删除,修改方法时可以访问以下route地址:
<li style="font-size: 11px;"> {{ $person->id }}
<form method="POST" action="people/{{$person->id}}">
@csrf @method('DELETE')
<button type="submit">Delete</button>
</form>
<form method="POST" action="people/{{$person->id}}">
@csrf @method('PUT')
<input type="text" name="people_name" placeholder="姓名">
<input type="text" name="team_id" placeholder="所属群组">
<button type="submit">Update</button>
</form>
</li>
在web.php下编写指定访问地址时。
Route::get('/people', function () {
return view('people/index.blade');
});