From f4aab0bed348e51315d574682ad745e9ec300eec Mon Sep 17 00:00:00 2001 From: UronShrestha Date: Tue, 9 Jul 2024 11:44:05 +0545 Subject: [PATCH] Order History View and Track Orders --- app/Http/Controllers/MainController.php | 31 +++++ public/css/style.css | 4 + resources/views/components/footer.blade.php | 17 ++- resources/views/components/header.blade.php | 43 ++++--- resources/views/orders.blade.php | 123 ++++++++++++++++++++ routes/web.php | 19 +-- 6 files changed, 214 insertions(+), 23 deletions(-) create mode 100644 resources/views/orders.blade.php diff --git a/app/Http/Controllers/MainController.php b/app/Http/Controllers/MainController.php index a9c2fb6..278ac04 100644 --- a/app/Http/Controllers/MainController.php +++ b/app/Http/Controllers/MainController.php @@ -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')) { diff --git a/public/css/style.css b/public/css/style.css index e758eb3..3fffb2c 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -3856,4 +3856,8 @@ ol { .categories__text:before { height: 250px; } + + .custom-upward { + margin-top: -20px; /* Adjust the value as needed */ + } } \ No newline at end of file diff --git a/resources/views/components/footer.blade.php b/resources/views/components/footer.blade.php index 67f176b..8f0feb6 100644 --- a/resources/views/components/footer.blade.php +++ b/resources/views/components/footer.blade.php @@ -88,7 +88,20 @@ - + + + + + + +{{-- Datatables script --}} + + + + diff --git a/resources/views/components/header.blade.php b/resources/views/components/header.blade.php index 9b57064..676e235 100644 --- a/resources/views/components/header.blade.php +++ b/resources/views/components/header.blade.php @@ -22,8 +22,24 @@ - - + + + {{-- bootstrap --}} + + + + + + + + + + + + +{{-- --}} + + @@ -78,10 +94,10 @@