这是我确认订单已送达的按钮
@elseif($order->order_status == 'Confirmed')
<div >
<form enctype="multipart/form-data" action="{{route('updateorderstatus',['order'=>$order->id])}}" method="post" >
@csrf
<input name="order_id" type="hidden" value="{{$order->id}}"/>
<input name="order_status" type="hidden" value="Shipping"/>
<a data-toggle="tooltip" data-placement="top" title="">
<button type="submit" class="btn btn-link">
<i class="fa fa-plane" aria-hidden="true"></i>
</button>
</a>
</form>
</div>
@elseif( $order->order_status == 'Shipping' )
<div class="btn-group" role="group" aria-label="Third group">
<form enctype="multipart/form-data" action="{{route('updateorderstatus')}}" method="post" >
@csrf
<input name="order_id" type="hidden" value="{{$order->id}}"/>
<input name="order_status" type="hidden" value="Delivered"/>
<input name="quantity" type="hidden" value="{{$order->quantity}}"/>
<input name="product_id" type="hidden" value="{{$order->product_id}}"/>
<a data-toggle="tooltip" data-placement="top" title="">
<button type="submit" class="btn btn-link">
<i class="fa fa-check-square-o" aria-hidden="true"></i>
</button>
</a>
</form>
</div>
更新订单状态和我尝试减少数量的功能
public function updateorderstatus(Request $request)
{
$order = Order::all();
if ($request->isMethod('post') ){
$data = $request->all();
Order::where('id',$data['order_id'])->update(['order_status'=>$data['order_status']]);
$current = Order::where('order_status','Delivered')->get();
Dvproduct::where('product_id',$data['product_id'])->update( ['quantity'=>$current - $data['quantity']] );
}
return back();
}
我有两个错误
当我点击第一个按钮 Undefined index: product_id
当我点击第二个 Object of class Illuminate\Database\Eloquent\Collection could not be converted to number
1条答案
按热度按时间to94eoyn1#
这里稍加修改,还尝试为订购按钮制作另一个功能和路线
改变
到
现在可以了