bug fixes, leave managment refactoring, report points
This commit is contained in:
@@ -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']);
|
||||
|
||||
Reference in New Issue
Block a user