Order History View and Track Orders

This commit is contained in:
UronShrestha
2024-07-09 11:44:05 +05:45
parent a1835247d6
commit f4aab0bed3
6 changed files with 214 additions and 23 deletions

View File

@ -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')) {