I am new to shopping cart. I am able to get all the data from order table on this page but i am not able to find single order by ID: This is my view page where i am sending the $id to the controller of the order. id)}}">Order# The whole code: '''
@foreach($orders as $order) @if($order->status == "CompletedOrders")
<div class="panel panel-default">
<div class="panel-body">
<ul class="list-group" >
<li class="list-group-item" style="background-color: #5C94ED">
<a href=""><h1 style="color: #FBEB58">Order# </h1></a>
<span class="badge" style="color: black; font-size: 16px">Name: </span>
<br>
<span class="badge" style="color: black; font-size: 16px">Phone: </span>
<br>
@foreach($order->cart->items as $item)
<span class="badge" style="color: #FBEB58; font-size: 16px"> </span>
<br>
<span class="badge" style="color: #FBEB58; font-size: 16px">Price: $</span>
<br>
@endforeach
<span class="badge" style="color: black; font-size: 16px">Instructions: </span>
<br>
<span class="badge" style="color: black; font-size: 16px">Time: </span>
<br>
</ul>
</div>
<div class="panel-footer">
<strong style="color: #222D32; font-size: 18px">Total Price: $</strong>
</div>
</div>
<input type="button" onclick="printDiv('printableArea')" value="print a div" />
@endif
@endforeach
''' This is my route
'''
Route::get('showcompleteorder/{id}','OrderController@showCompleteOrder')->name('showcompleteorder');
''' and this is my controller:
public function showCompleteOrder($id){
$orders = Order::find($id);
$orders->transform(function ($order, $key) {
$order->cart = unserialize($order->cart);
return $order;
});
return view('orders.showcompleteorders', ['orders' => $orders]);
}
but when i run this. it gives me a error of transform:
BadMethodCallException
Call to undefined method App\Order::transform() http://localhost:8000/showcompleteorder/2
This is my view where i am trying to get the order by id:
@foreach($orders as $order)
<div class="panel panel-default">
<div class="panel-body">
<ul class="list-group" >
<li class="list-group-item" style="background-color: #5C94ED">
<h1 style="color: #FBEB58">Order# </h1>
<span class="badge" style="color: black; font-size: 16px">Name: </span>
<br>
<span class="badge" style="color: black; font-size: 16px">Phone: </span>
<br>
@foreach($order->cart->items as $item)
<span class="badge" style="color: #FBEB58; font-size: 16px"> </span>
<br>
<span class="badge" style="color: #FBEB58; font-size: 16px">Price: $</span>
<br>
@endforeach
<span class="badge" style="color: black; font-size: 16px">Instructions: </span>
<br>
<span class="badge" style="color: black; font-size: 16px">Time: </span>
<br>
</ul>
</div>
<div class="panel-footer">
<strong style="color: #222D32; font-size: 18px">Total Price: $</strong>
</div>
</div>
@endforeach
Can Someone please help me
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire