我正在尝试根据所选选项显示数据库中的所有订单。 这两个选项是Accepted和Declined。 我有一个包含“status”列的订单表
在我看来,我显示所有订单,这没关系。 我还希望根据顶部的状态显示数据。 非常感谢帮助。
我的观点:
<h1 class="text text-center">Orders Page</h1>
<div class="panel panel-warning">
<div class="panel-heading">
<p>Returning an array of all orders, filtered by status</p>
<select>
<option>Accepted</option>
<option>Declined</option>
</select>
</div>
<div class="panel-body">
Display Data here
</div>
</div>
@foreach ($orders as $order)
<div class="panel panel-primary">
<div class="panel panel-heading">
<p>Order Number: {{$order->id}} for retailerr: {{$order->retailerId}}</p>
</div>
<div class="panel panel-body">
<p>The Status of this order: @if ($order->status == '') <span style="color: red"> Pending approval </span>@else {{$order->status}} @endif</p>
<p><a href="{{URL('orders/'.$order->id.'/edit')}}" class="btn btn-primary">Change Order Status</a>
<a href="{{URL('orders/'.$order->id)}}" class="btn btn-success">View Order Details</a>
{!! Form::open(array("method"=>"DELETE", "url"=>"orders/$order->id")) !!}
{!! Form::submit("Delete Order", array("class"=>"btn btn-danger")) !!}
{!! Form::close() !!}</p>
<p>The total for this order: {{$order->total}}</p>
</div>
<div>
<h5 class="text-center">Order by: {{$order->user->firstName}} {{$order->user->lastName}}</h5>
</div>
</div>
@endforeach
控制器索引方法:
public function index()
{
//
$data = Order::all();
return view('orders.orderDashboard')->with("orders", $data);
}
答案 0 :(得分:0)
ord