From d8e17eef70045049f7276129af66a00ab4895403 Mon Sep 17 00:00:00 2001 From: UronShrestha Date: Mon, 15 Jul 2024 11:23:50 +0545 Subject: [PATCH] "Updated MainController, OrderItem model, adminheader, footer, header, and orders blade files with changes to myOrders function, datatables, and modal implementation." --- app/Http/Controllers/MainController.php | 42 +++- app/Models/OrderItem.php | 1 + .../views/components/adminheader.blade.php | 2 +- resources/views/components/footer.blade.php | 9 +- resources/views/components/header.blade.php | 14 +- resources/views/orders.blade.php | 209 +++++++++++------- 6 files changed, 179 insertions(+), 98 deletions(-) diff --git a/app/Http/Controllers/MainController.php b/app/Http/Controllers/MainController.php index 40a78ad..d4a312c 100644 --- a/app/Http/Controllers/MainController.php +++ b/app/Http/Controllers/MainController.php @@ -214,15 +214,49 @@ class MainController extends Controller } + // public function myOrders() + // { + // if (session()->has('id')) { + // $orders = Order::where('customerId', session()->get('id'))->get(); + // // dd($orders); + // $items = DB::table('products') + // ->join('order_items', 'order_items.productId', '=', 'products.id') + // ->select('products.name', 'products.picture', 'products.*') + // ->get(); + + // return view('orders', compact('orders', 'items')); + // } + + // return view('login'); + // } + + //old myOrders + // public function myOrders() + // { + // if (session()->has('id')) { + // $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.*', 'order_items.orderId') + // ->get(); + + // return view('orders', compact('orders', 'items')); + // } + + // return view('login'); + // } + + //new myOrders public function myOrders() { if (session()->has('id')) { $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.*') + ->select('products.name', 'products.picture', 'order_items.*') + ->get(); return view('orders', compact('orders', 'items')); @@ -232,6 +266,8 @@ class MainController extends Controller } + + public function profile() { if (session()->get('type') == 'Customer') { diff --git a/app/Models/OrderItem.php b/app/Models/OrderItem.php index 029b797..7e571c8 100644 --- a/app/Models/OrderItem.php +++ b/app/Models/OrderItem.php @@ -8,4 +8,5 @@ use Illuminate\Database\Eloquent\Model; class OrderItem extends Model { use HasFactory; + } diff --git a/resources/views/components/adminheader.blade.php b/resources/views/components/adminheader.blade.php index 883a769..ff4092b 100644 --- a/resources/views/components/adminheader.blade.php +++ b/resources/views/components/adminheader.blade.php @@ -31,7 +31,7 @@ - + diff --git a/resources/views/components/footer.blade.php b/resources/views/components/footer.blade.php index bfa58cf..20cf8c5 100644 --- a/resources/views/components/footer.blade.php +++ b/resources/views/components/footer.blade.php @@ -107,13 +107,14 @@ -{{-- Datatables script --}} - - + + + + - - -{{-- --}} - + + + diff --git a/resources/views/orders.blade.php b/resources/views/orders.blade.php index 7b97ba4..5048a2c 100644 --- a/resources/views/orders.blade.php +++ b/resources/views/orders.blade.php @@ -1,70 +1,159 @@ +
-
+ +

My Orders

-
- @if (session('success')) -
- {{ session('success') }} -
- @endif - - @if (session('error')) -
- {{ session('error') }} -
- @endif - - @if ($errors->any()) -
-
    - @foreach ($errors->all() as $error) -
  • {{ $error }}
  • - @endforeach -
-
- @endif - - +
+
+ {{-- --}} + - @foreach ($orders as $order) + @php + $i = 0; + @endphp + @foreach ($orders as $item) + @php + $i++; + @endphp - - - - - - - + + + + {{-- --}} + + + + + @endforeach + + + +
S.No. Name AddressDescriptionPhone Status Order Date Total Bill View Products
{{ $loop->iteration }}{{ $order->name }}{{ $order->address }}{{ $order->phone }}{{ $order->status }}{{ $order->created_at }}{{ $order->bill }}{{ $i }}{{ $item->name }}{{ $item->address }}{{ $item->description }}{{ $item->phone }}{{ $item->status }}{{ $item->created_at }}{{ $item->bill }} - - + + +
+
@@ -72,52 +161,6 @@
- -@foreach ($orders as $order) - -@endforeach - -