标签:str bsp where 修改 put stat ret load() ken
1 @if($v->fang_status==1) 2 <span class="label label-info radius zhuangtaiUp" id="zhuangtaiUp" href="{{route(‘admin.zhuangtaiUp‘,[‘id‘=>$v->id])}}" where="1">展示{{$v->id}}</span> 3 @else 4 <span class="label label-success radius zhuangtaiUp" id="zhuangtaiUp" href="{{route(‘admin.zhuangtaiUp‘,[‘id‘=>$v->id])}}" where="0">隐藏{{$v->id}}</span> 5 @endif
<span class="label label-danger radius" href="{{route(‘admin.book.destroy‘,$v[‘id‘])}}">删除</span>
<script type="text/javascript"> $(‘.zhuangtaiUp‘).click(function () { let that=this let url=$(this).attr(‘href‘) let where=$(this).attr(‘where‘) //发送ajax $.ajax({ url:url, type:‘get‘, data:{ _token:"{{csrf_token()}}", where:where }, dataType: "json", success: function(msg){ if (msg.code==200){ location.reload() }else { alert(‘修改失败‘) } } }) }) //删除 $(".label-danger").click(function () { let that=this let url=$(this).attr(‘href‘); $.ajax({ url:url, type:"DELETE", data:{ _token:"{{csrf_token()}}" }, dataType: "json", success: function(msg){ alert( "Data Saved: " + msg ); } }) }) </script>
//删除 public function destroy(Book $Book) { // $fang->delete(); return [‘code‘=>200,‘msg‘=>‘删除成功‘]; } //状态 public function zhuangtaiUp(Request $request){ //过滤 $id=$request->input(‘id‘); if (!is_numeric($id)){ return [‘code‘=>500,‘msg‘=>‘参数id不正确‘]; } $data=Book::where(‘id‘,$id)->first(); $zhuangtaiUp=$data[‘book_status‘]; if ($zhuangtaiUp==1){ Book::where(‘id‘,$id)->update([‘book_status‘=>"0"]); return [‘code‘=>200,‘msg‘=>‘success‘,‘data‘=>‘‘]; }else{ Book::where(‘id‘,$id)->update([‘book_status‘=>1]); return [‘code‘=>200,‘msg‘=>‘success‘,‘data‘=>‘‘]; } }
标签:str bsp where 修改 put stat ret load() ken
原文地址:https://www.cnblogs.com/cyxng/p/14342649.html