bug fixes, leave managment refactoring, report points

This commit is contained in:
Kwesi Banson
2026-11-03 12:05:59 +00:00
parent 965892ac62
commit b393dcdf0e
14 changed files with 144 additions and 117 deletions

View File

@@ -11,25 +11,24 @@ class ManagementDashboardController extends Controller
{
public function index(Request $request)
{
// 1. Fetch Pending Leaves (Adjust status/model names to match your schema)
$pendingLeaves = LeaveRequest::with('staff')
->where('status', 'Pending')
->orderBy('created_at', 'asc')
->get();
$startDate = $request->input('start_date', Carbon::now()->startOfMonth()->format('Y-m-d'));
$endDate = $request->input('end_date', Carbon::now()->endOfMonth()->format('Y-m-d'));
$staffReports = StaffMember::withCount(['dailyReports' => function ($query) use ($startDate, $endDate) {
$query->whereBetween('report_date', [$startDate, $endDate]);
}])
->orderBy('name')
->get();
$staffReports = StaffMember::where('department_id', '!=', 5)
->withCount(['dailyReports' => function ($query) use ($startDate, $endDate) {
$query->whereBetween('report_date', [$startDate, $endDate]);
}])
->orderBy('name')
->get();
return view('management.index', compact('pendingLeaves', 'staffReports', 'startDate', 'endDate'));
}
public function updateLeaveStatus(Request $request, $id)
{
$request->validate(['status' => 'required|in:Approved,Rejected']);