make(DailySummaryRetriever::class); $now = Carbon::today(); $absences = $dailySummaryRetriever->getAbsences($now) ->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name); $remoteDays = $dailySummaryRetriever->getRemoteDays($now) ->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name); $birthdays = $dailySummaryRetriever->getBirthdays($now) ->map(fn(User $user): string => $user->profile->full_name); $absencesAttachment = Attachment::create() ->setTitle("Nieobecności :sunny:") ->setColor("#eab308") ->setText($absences->isNotEmpty() ? $absences->implode("\n") : "Wszyscy dzisiaj pracują :muscle:"); $remoteAttachment = Attachment::create() ->setTitle("Praca zdalna :house_with_garden:") ->setColor("#527aba") ->setText($remoteDays->isNotEmpty() ? $remoteDays->implode("\n") : "Wszyscy dzisiaj są w biurze :boom:"); $birthdayAttachment = Attachment::create() ->setTitle("Urodziny :birthday:") ->setColor("#3c5f97") ->setText($birthdays->isNotEmpty() ? $birthdays->implode("\n") : "Dzisiaj nikt nie ma urodzin :cry:"); return $this->respondToSlack("Podsumowanie dla dnia {$now->toDisplayString()}") ->withAttachment($absencesAttachment) ->withAttachment($remoteAttachment) ->withAttachment($birthdayAttachment); } }