路由中间件-2 资源控制器 伪造表单方法

在这里插入图片描述

路由中间件-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/student3indexstudent3.index显示资源列表
GET/student3/createcreatestudent3.create创建资源
POST/student3storestudent3.store存储资源
GET/student3/{id}showstudent3.show显示指定的资源
GET/student3/{id} /editeditstudent3.edit显示用于编辑指定资源的表单
PUT/PATCH/student3/{id}updatestudent.update编辑更新存储中的指定资源
DELETE/student3/{id}destroystudent.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>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值