repository = $repository; } public function execute() { $Orders= $this->repository->whereYear('created_at', '=', Carbon::now()->year) ->whereMonth('created_at', '=', Carbon::now()->month)->where('company_id', '!=', 349)->orderBy('created_at')->get(); $group = $Orders->groupBy(function($item) { return Carbon::parse($item->created_at)->format('j'); }); $groupCount = $group->map(function ($item) { return collect($item)->count(); })->toArray(); $report = []; for($x = 1; $x <= Carbon::now()->daysInMonth; $x++) { $report[] = isset($groupCount[$x]) ? $groupCount[$x] : 0; } return $report; } }