我无法更改“表列”的状态表的列名为“number”与控制器中的输入“表”匹配

7jmck4yq  于 2021-07-24  发布在  Java
关注(0)|答案(1)|浏览(312)
public function complete(Request $request, $id){
    $order = Order::find($id);

    // Update the Order
    $value =  $request->input('table');
    $number = DB::table('tables')->where('number' , '=' , $value)->update(['status' => "Fine"]);
    $order->update(['status' => 'CompletedOrders']);

    return redirect()->route('servedorders');
}

我给表输入赋值了一个变量。然后我尝试将这个变量与表中的列进行匹配。但我无法将值更新为“free”。我的询问有什么问题吗?
所有价值都来自何处。

@foreach($orders as $order)
                @if($order->status == "OrdersServed")
                    <div class="panel panel-default">
                        <div class="panel-body">
                            <ul class="list-group" >

                                <li class="list-group-item" style="background-color: #467aeb">
                                    <a href="{{route('showcompleteorder',$order->id)}}"><h1 style="color: #051942; font-family: Helvetica; font-weight: bold">Order# {{$order->id}}</h1></a>
                                    <span class="label label-success"><p style="font-size: 15px; color: white">Name: <b>{{$order->name}}</b></p></span>
                                    <span class="label label-success"><p style="font-size: 15px; color: white">Phone: <b>{{$order->phone}}</b></p></span>
                                    @foreach($order->cart->items as $item)
                                        <span class="label label-success"><p style="font-size: 15px; color: #051942"><b>{{$item['qty'] }} {{ $item['item']['name'] }} </b></p></span>
                                        <span class="label label-success"><p style="font-size: 15px; color: #051942">Price: <b>₹{{ $item['price'] }}</b></p></span>
                                    @endforeach
                                    <span class="label label-success"><p style="font-size: 15px; color: white">Table: <b>{{$order->table}}</b></p></span>
                                    <br>
                                    <span class="badge" style="color: #051942; font-size: 16px">Order Time: {{$order->created_at}}</span>
                                    <br>
                                    @if($order->status == 'OrdersServed')
                                        <a class="btn btn-block btn-info btn-flat" style="font-size: 20px" href="{{route('complete', $order->id)}}">Order Completed</a>
                                @endif

提前谢谢。

ryevplcw

ryevplcw1#

您的视图不包含 <input> 随信寄 $requestcomplete 功能,所以 $request->input('table') 正在返回空值。
但我能看见你的眼睛 order 不包含 table ,您将发送订单 idcomplete 函数,以便使用:

$order = Order::find($id);

// Update the Order
$number = DB::table('tables')->where('number' , '=' , $order->table)->update(['status' => "Fine"]);
$order->update(['status' => 'CompletedOrders']);

相关问题