public function show($orderId = null)
{
$orders = Store\Order::with('user', 'address', 'address.country', 'items.product');
if ($orderId) {
$orders->where('orders.order_id', $orderId);
} else {
$orders->where('orders.status', 'paid');
}
$ordersItemsQuantities = Store\Order::itemsQuantities($orders);
$orders = $orders->orderBy('created_at')->get();
$productId = (int) Request::input('product');
if ($productId) {
$orders = $orders->filter(function ($order) use($productId) {
return $order->items()->where('product_id', $productId)->exists();
});
}
return view('admin.store.orders.show', compact('orders', 'ordersItemsQuantities'));
}