laraver框架 资源路由的删除 修改如何使用
资源路由示例:
Route::resource('user','UserController');
使用:
修改页面跳转
<a class="label label-secondary radius updata" href='{{route("user.edit",$v['id'])}}'>修改</a>
执行修改:
<form method="post" action="{{route('user.update',$user)}}">
@method('PUT')
删除:
1 <a class="label label-danger radius delete" id="dest" data-href='{{route("user.destroy",$v['id'])}}'>删除</a> 2 3 $(function () { 4 $("#dest").click(function () { 5 let url=$("#dest").attr('data-href'); 6 $.ajax({ 7 type: "DELETE", 8 url: url, 9 dataType:"json", 10 data:{ 11 _token:"{{csrf_token()}}" 12 }, 13 success: function(msg){ 14 if (msg.code==200){ 15 layer.msg(msg.msg,{icon:1,time:200},()=>{ 16 location.reload() 17 }) 18 } 19 } 20 }); 21 22 23 }) 24 25 })