Order History View and Track Orders
This commit is contained in:
@ -185,6 +185,37 @@ class MainController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function myOrders()
|
||||
{
|
||||
$customerId = auth()->id(); // Assuming you are using authentication
|
||||
$orders = Order::where('customerId', session()->get('id'))->get();
|
||||
|
||||
$items = DB::table('products')
|
||||
->join('order_items', 'order_items.productId', '=', 'products.id')
|
||||
->select('products.name', 'products.picture', 'products.price', 'order_items.quantity', 'order_items.orderId as order_id')
|
||||
->whereIn('order_items.orderId', $orders->pluck('id'))
|
||||
->get();
|
||||
|
||||
return view('orders', compact('orders', 'items'));
|
||||
}
|
||||
|
||||
|
||||
// public function myOrders()
|
||||
// {
|
||||
// $customerId = auth()->id(); // Assuming you are using authentication
|
||||
// $orders = Order::where('customerId', session()->get('id'))->get();
|
||||
|
||||
// $items = DB::table('products')
|
||||
// ->join('order_items', 'order_items.productId', '=', 'products.id')
|
||||
// ->select('products.name', 'products.picture', 'products.price', 'order_items.quantity', 'order_items.orderId as order_id')
|
||||
// ->whereIn('order_items.orderId', $orders->pluck('id'))
|
||||
// ->get();
|
||||
|
||||
// return view('orders', compact('orders', 'items'));
|
||||
// }
|
||||
|
||||
|
||||
public function profile()
|
||||
{
|
||||
if (session()->has('id')) {
|
||||
|
Reference in New Issue
Block a user