From 7670867b625a49c997eb2c456777656a998904d3 Mon Sep 17 00:00:00 2001 From: UronShrestha Date: Tue, 16 Jul 2024 13:50:22 +0545 Subject: [PATCH] "Updated AdminController and orders.blade.php to display order items, added modal to view order details, and made minor changes to adminheader.blade.php" --- app/Http/Controllers/AdminController.php | 30 +- resources/views/Dashboard/orders.blade.php | 307 +++++++++++++++--- .../views/components/adminheader.blade.php | 1 + resources/views/orders.blade.php | 18 - 4 files changed, 290 insertions(+), 66 deletions(-) diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php index 8f37d3a..6a0e21b 100644 --- a/app/Http/Controllers/AdminController.php +++ b/app/Http/Controllers/AdminController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers; use Illuminate\Support\Facades\DB; use App\Models\User; use App\Models\Order; +use App\Models\OrderItem; @@ -194,19 +195,44 @@ class AdminController extends Controller return redirect()->back(); } - + //old orders public function orders() { if (session()->get('type') == 'Admin') { + $orderItems = DB::table('order_items') + ->join('products', 'order_items.productId', 'products.id') + ->select('products.name', 'products.picture', 'order_items.*') + ->get(); + $orders = DB::table('users') ->join('orders', 'orders.customerId', 'users.id') ->select('orders.*', 'users.name', 'users.email', 'users.status as userStatus') ->get(); - return view('Dashboard.orders', compact('orders')); + return view('Dashboard.orders', compact('orders', 'orderItems')); } return redirect()->back(); } + //new orders + // public function orders() + // { + // if (session()->get('type') == 'Admin') { + // $orderItems = DB::table('order_items') + // ->join('products', 'order_items.productId', 'products.id') + // ->select('products.name as productName', 'products.picture', 'order_items.*') + // ->get(); + + // $orders = DB::table('users') + // ->join('orders', 'orders.customerId', 'users.id') + // ->select('orders.*', 'users.name as userName', 'users.email', 'users.status as userStatus') + // ->get(); + + // return view('Dashboard.orders', compact('orders', 'orderItems')); + // } + // return redirect()->back(); + // } + + public function changeOrderStatus($status, $id) { diff --git a/resources/views/Dashboard/orders.blade.php b/resources/views/Dashboard/orders.blade.php index 99e9a91..4cbd243 100644 --- a/resources/views/Dashboard/orders.blade.php +++ b/resources/views/Dashboard/orders.blade.php @@ -1,5 +1,190 @@ +{{-- new --}} + +
+
+
+
+
+
+

Welcome Aamir

+
All systems are running smoothly!
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+

Our Orders

+
+ + + + + + + + + + + + + + + + + + @foreach ($orders as $order) + + + + + + + + + + + + + + @endforeach + +
IDCustomer Name Customer StatusPhoneAddressEmailBill StatusViewOrder DateActions
{{ $loop->iteration }}{{ $order->name }} + @if ($order->userStatus == 'Active') + Active + @else + Blocked + @endif + {{ $order->phone }}{{ $order->address }}{{ $order->email }}NRs {{ $order->bill }} +
+ {{ $order->status }} +
+
+ + + {{ $order->created_at }} + @if ($order->status == 'Paid') + Accept + Reject + @elseif ($order->status == 'Accepted') + Completed + @elseif ($order->status == 'Delivered') + Deliver Complete + @else + Accept + @endif +
+
+ + + @foreach ($orders as $order) + + @endforeach +
+
+
+
+
+ + + + + + + + + + {{-- +
@@ -38,38 +223,7 @@
- - {{-- --}} - -

Our Orders

@@ -84,6 +238,7 @@ Email Bill Status + View Order Date Actions @@ -119,24 +274,84 @@
{{ $order->status }}
+ + + + + + @foreach ($orders as $order) + + @endforeach + - {{-- @if ($order->status == 'Pending') - Pending - @elseif ($order->status == 'Paid') - Paid - @elseif ($order->status == 'Delivered') - Delivered - @elseif ($order->status == 'Rejected') - Rejected - @endif - --}} {{ $order->created_at }} @if ($order->status == 'Paid') @@ -170,4 +385,4 @@
- + --}} diff --git a/resources/views/components/adminheader.blade.php b/resources/views/components/adminheader.blade.php index 7d39125..c4cb74a 100644 --- a/resources/views/components/adminheader.blade.php +++ b/resources/views/components/adminheader.blade.php @@ -11,6 +11,7 @@ --}} + diff --git a/resources/views/orders.blade.php b/resources/views/orders.blade.php index 491499f..0e0071a 100644 --- a/resources/views/orders.blade.php +++ b/resources/views/orders.blade.php @@ -74,24 +74,6 @@ - {{-- old tbody --}} - {{-- - @foreach ($items as $product) - @if ($product->order_id == $item->id) - - {{ $product->name }} - - {{ $product->quantity }} - {{ $product->price }} - {{ $product->price * $product->quantity }} - - - @endif - @endforeach - --}} - {{-- new tbody --}} @foreach ($items as $product)