路由中间件-2
apche 区分不同的域名时通过HTTP请求中Host请求头
laravel.learn => laravel/public
lamp207.net => thinkphp5/public
中间件:(保安:守门)
做记录和判断
kennel:核心、要点
视频剪辑:
AE
Sony Vagas
资源控制器
简化路由规则——一条顶七条
创建控制器
php artisan make:controller Student3Controller -r
创建路由规则
Route:resource('student3','Student3Controller')
路由规律
动作 | URL | 行为 | 路由名称 | |
---|---|---|---|---|
GET | /student3 | index | student3.index | 显示资源列表 |
GET | /student3/create | create | student3.create | 创建资源 |
POST | /student3 | store | student3.store | 存储资源 |
GET | /student3/{id} | show | student3.show | 显示指定的资源 |
GET | /student3/{id} /edit | edit | student3.edit | 显示用于编辑指定资源的表单 |
PUT/PATCH | /student3/{id} | update | student.update | 编辑更新存储中的指定资源 |
DELETE | /student3/{id} | destroy | student.destroy | 从存储中删除指定的资源 |
store:
<form action="/student3/80" method="post">
(create对应store)
<form action="{{url('/student3')}}" method="POST">
{{--{{csrf_field()}}--}}
<input type="text" name="abc">
{{csrf_field()}}
<button type="submit">提交</button>
</form>
update:
{{method_field(‘PUT’)}}
destroy:
{{method_field(‘DELETE’)}}
伪造表单方法
(edit对应update、destroy)
<form action="/student3/80" method="post">
{{csrf_field()}}
{{--伪造put表单方法--}}
{{method_field('PUT')}}
<input type="text" name="abc">
<button>提交</button>
</form>
<h2>删除</h2>
<form action="/student3/80" method="post">
{{csrf_field()}}
{{--伪造put表单方法--}}
{{method_field('DELETE')}}
<input type="text" name="abc">
<button>删除</button>
</form>