"Added orders management functionality to AdminController, including orders listing and status update, and updated routes and admin header view accordingly."
This commit is contained in:
@ -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();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user