Feste Profilfelder in Formularen, Geburtstage, anpassbare Startseite
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 2m18s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 2m21s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 2m40s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 2m34s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 3m8s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 3m6s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 2m43s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 2m47s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m1s

- Formulare: Felder fest aus dem Profil (nicht änderbar, Server setzt den
  Profilwert ein), Hinweis bei fehlender Profilangabe
- Geburtstage (optionales Plugin, standardmäßig aus): Tag und Monat freiwillig
  im Profil, Kachel, Liste /geburtstage, Pagebuilder-Block, Glückwunsch am
  eigenen Geburtstag; Sichtbarkeit alle/Abteilung/Standort
- Startseite: Kacheln je Bereich sortieren und ausblenden; eigene Kacheln
  (Bild mit Link, Text, Hinweis) mit Zeitraum und Zielgruppe
- Kern: optionale mitgelieferte Plugins, Startseitenbereich „top“,
  Profilabschnitte für Plugins, Kachel-Bezeichnungen

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Friederich Loheide 2026-09-26 09:51:19 +00:00
parent 435960725d
commit ee8dde93c0
262 changed files with 2385 additions and 692 deletions

View file

@ -0,0 +1,60 @@
<?php
namespace Inhaus\Plugins\Birthdays;
use App\Dashboard\Widgets;
use App\Models\User;
use App\Pagebuilder\Blocks;
use App\Pagebuilder\BlockType;
use App\Pagebuilder\Field;
use App\Plugins\Plugin;
use App\Profile\ProfileSections;
use Inhaus\Plugins\Birthdays\Models\Birthday;
/**
* Freiwillige Geburtstagsliste. Standardmäßig aus – im Admin unter „Plugins“ aktivierbar.
*/
class BirthdaysPlugin extends Plugin
{
public function register(): void
{
$this->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));
}
}