Welcome back! I guess this is the continuation of your last question. I modifies your code:
$startOfMonth = Carbon::now()->startOfMonth();
$endOfMonth = Carbon::now()->endOfMonth();
$uptimeData = Ticket::whereBetween('created_at', [$startOfMonth->format('Y-m-d 07:00:00'), $endOfMonth->format('Y-m-d 15:00:00')])
->orderBy('created_at', 'asc')
->select('ticket_Id', 'created_at')
->get();
// rest of the code remains the same
And to automate the monthly count and have monthly reports for each year, you can use a for loop to iterate through the months in a year, get the start and end of each month and perform the count.
for ($month = 1; $month <= 12; $month++) {
$startOfMonth = Carbon::now()->month($month)->startOfMonth();
$endOfMonth = Carbon::now()->month($month)->endOfMonth();
$uptimeData = Ticket::whereBetween('created_at', [$startOfMonth->format('Y-m-d 07:00:00'), $endOfMonth->format('Y-m-d 15:00:00')])
->orderBy('created_at', 'asc')
->select('ticket_Id', 'created_at')
->get();
// rest of the code remains the same
// store the result of the monthly count in an array or database to view the reports
}

