Add summary counts to the index page
Concept
A dashboard in a hangar shows how many aircraft are in each maintenance status -- 3 pending, 2 in progress, 5 completed. This gives the team an instant overview. You will add the same kind of summary to your index page: counts of how many maintenance logs are in each status (pending, in-progress, completed). This helps the technician see the overall picture at a glance.
Apply
Modify the index() method in your controller to calculate status counts and pass them to the view. Then update index.blade.php to display the counts above the table.
Prompt
Expected Result
The index page should show three summary cards at the top: "X Pending" (with a number), "Y In Progress" (with a number), and "Z Completed" (with a number). These counts should update automatically when you create, update, or delete log entries.
Troubleshooting
- • If the counts all show 0, make sure you have log entries in the database. Also check that the status values match exactly: "pending", "in-progress", "completed" (not "In Progress" or "in_progress").
- • If you see "Undefined variable: pendingCount", make sure the index() method is passing the count variables to the view using compact() or the with() method.