diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php index 66bea7f..8f37d3a 100644 --- a/app/Http/Controllers/AdminController.php +++ b/app/Http/Controllers/AdminController.php @@ -2,8 +2,10 @@ namespace App\Http\Controllers; -use Illuminate\Support\Facades\URL; +use Illuminate\Support\Facades\DB; use App\Models\User; +use App\Models\Order; + use Illuminate\Http\Request; @@ -191,4 +193,29 @@ class AdminController extends Controller } return redirect()->back(); } + + + public function orders() + { + if (session()->get('type') == 'Admin') { + $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 redirect()->back(); + } + + + public function changeOrderStatus($status, $id) + { + if (session()->get('type') == 'Admin') { + $order = Order::find($id); + $order->status = $status; + $order->save(); + return redirect()->back()->with('success', 'Order Status Changed Successfully'); + } + return redirect()->back(); + } } diff --git a/resources/views/Dashboard/orders.blade.php b/resources/views/Dashboard/orders.blade.php new file mode 100644 index 0000000..99e9a91 --- /dev/null +++ b/resources/views/Dashboard/orders.blade.php @@ -0,0 +1,173 @@ + + + +
+
+
+
+
+
+

Welcome Aamir

+
All systems are running smoothly! +
+
+
+
+ +
+
+
+
+
+ + + +
+
+
+
+ + {{-- --}} + + + +

Our Orders

+
+ + + + + + + + + + + + + + + + + @php + $i = 0; + @endphp + @foreach ($orders as $order) + @php + $i++; + @endphp + + + + + + + + + + --}} + + + + @endforeach + + +
IDCustomer Name Customer StatusPhoneAddressEmailBill StatusOrder DateActions
{{ $i }}{{ $order->name }} + @if ($order->userStatus == 'Active') + Active + @else + Blocked + @endif + + + {{ $order->phone }}{{ $order->address }}{{ $order->email }}NRs {{ $order->bill }} +
+ {{ $order->status }} +
+ + + + + {{-- @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') + Accept + Reject + @elseif ($order->status == 'Accepted') + Completed + @elseif ($order->status == 'Delivered') + Deliver Complete + @else + Accept + @endif +
+ +
+
+
+
+ +
+ +
+ + + diff --git a/resources/views/components/adminheader.blade.php b/resources/views/components/adminheader.blade.php index 336a5e1..7d39125 100644 --- a/resources/views/components/adminheader.blade.php +++ b/resources/views/components/adminheader.blade.php @@ -389,7 +389,7 @@ diff --git a/routes/web.php b/routes/web.php index a926015..3aa3a96 100644 --- a/routes/web.php +++ b/routes/web.php @@ -19,7 +19,8 @@ Route::get('/deleteProduct/{id}', [AdminController::class, 'deleteProduct'])->na Route::get('/adminProfile', [AdminController::class, 'profile'])->name('adminProfile'); Route::get('/ourCustomers', [AdminController::class, 'customers'])->name('ourCustomers'); Route::get('/changeUserStatus/{status}/{id}', [AdminController::class, 'changeUserStatus'])->name('changeUserStatus'); - +Route::get('/changeOrderStatus/{status}/{id}', [AdminController::class, 'changeOrderStatus'])->name('changeOrderStatus'); +Route::get('/ourOrders', [AdminController::class, 'orders'])->name('ourOrders'); //customer routes