app->singleton(BirthdayList::class); $this->app->make(ProfileSections::class)->add('birthday', 'birthdays::ProfileBirthday', 10, function (User $user) { $birthday = Birthday::query()->where('user_id', $user->id)->first(); return [ 'birthday' => $birthday ? ['day' => $birthday->day, 'month' => $birthday->month] : null, 'months' => BirthdayList::months()->map(fn ($label, $value) => ['value' => $value, 'label' => $label])->values(), 'scope' => app(BirthdayList::class)->scope(), ]; }); $widgets = $this->app->make(Widgets::class); // Glückwunsch oben auf der Startseite – nur am eigenen Geburtstag. $widgets->add('birthdays.greeting', 'birthdays::Greeting', 'top', sort: 0, props: function (User $user) { $list = app(BirthdayList::class); return $list->greetingEnabled() && $list->isBirthdayToday($user) ? ['name' => $user->first_name ?: $user->name] : null; }, label: 'Geburtstagsgruß (am eigenen Geburtstag)', mobileSort: -100); $widgets->add('birthdays.upcoming', 'birthdays::Upcoming', 'aside', sort: 30, props: function (User $user) { $list = app(BirthdayList::class); $upcoming = $list->upcoming($user, limit: 8); return $upcoming === [] ? null : ['birthdays' => $upcoming, 'days' => $list->daysAhead()]; }, label: 'Geburtstage', mobileSort: 35); $this->app->make(Blocks::class)->add(BlockType::make('birthdays.list', 'Geburtstage', 'cake', 'dynamic', 'birthdays::BirthdaysBlock') ->description('Anstehende Geburtstage – z. B. auf der Seite einer Abteilung.') ->fields([ Field::text('title', 'Überschrift', 150, 'Geburtstage'), Field::select('scope', 'Wessen Geburtstage', ['' => 'Wie in den Einstellungen'] + BirthdayList::SCOPES, ''), Field::number('days', 'Tage im Voraus', 0, 60, 14), ]) ->resolveUsing(fn (array $data, ?User $user) => $user ? [ 'birthdays' => app(BirthdayList::class)->upcoming($user, $data['days'], $data['scope'] ?: null, 30), ] : null)); } }