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,104 @@
<?php
namespace App\Filament\Resources\DashboardTiles;
use App\Filament\Components\AudienceSection;
use App\Filament\Resources\DashboardTiles\Pages\ManageDashboardTiles;
use App\Models\DashboardTile;
use BackedEnum;
use Filament\Actions\DeleteAction;
use Filament\Actions\EditAction;
use Filament\Forms\Components\DateTimePicker;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Resources\Resource;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Components\Utilities\Get;
use Filament\Schemas\Schema;
use Filament\Support\Icons\Heroicon;
use Filament\Tables\Columns\IconColumn;
use Filament\Tables\Columns\ImageColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use UnitEnum;
/**
* Eigene Kacheln der Startseite. Reihenfolge und Ein-/Ausblenden unter „Startseite“.
*/
class DashboardTileResource extends Resource
{
protected static ?string $model = DashboardTile::class;
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedRectangleGroup;
protected static string|UnitEnum|null $navigationGroup = 'Portal';
protected static ?int $navigationSort = 11;
protected static ?string $modelLabel = 'Eigene Kachel';
protected static ?string $pluralModelLabel = 'Eigene Kacheln';
protected static ?string $slug = 'kacheln';
public static function canAccess(): bool
{
return auth()->user()?->can('appearance.manage') ?? false;
}
public static function form(Schema $schema): Schema
{
$type = fn (string ...$types) => fn (Get $get) => in_array($get('type'), $types, true);
return $schema->columns(2)->components([
TextInput::make('name')->label('Name (nur im Admin)')->required()->maxLength(100),
Select::make('type')->label('Art')->options(DashboardTile::TYPES)->default('image')->required()->live()->native(false),
Select::make('area')->label('Bereich')->options(DashboardTile::AREAS)->default('aside')->required()->native(false)
->helperText('Die Reihenfolge innerhalb des Bereichs legen Sie unter „Startseite“ fest.'),
TextInput::make('title')->label(fn (Get $get) => $get('type') === 'image' ? 'Bildunterschrift (optional)' : 'Überschrift')->maxLength(150),
FileUpload::make('image_path')->label('Bild')->image()->disk('uploads')->directory('dashboard')->visibility('public')
->maxSize(8 * 1024)->required($type('image'))->visible($type('image'))->columnSpanFull()
->helperText('Für die Seitenleiste z. B. 800 × 600 Pixel, für „ganz oben“ ein breites Banner (z. B. 2400 × 500).'),
TextInput::make('alt')->label('Alternativtext')->maxLength(200)->visible($type('image'))->helperText('Beschreibt das Bild für Screenreader.'),
RichEditor::make('body')->label('Text')->toolbarButtons([['bold', 'italic', 'link'], ['bulletList', 'orderedList'], ['undo', 'redo']])
->required($type('text', 'notice'))->visible($type('text', 'notice'))->columnSpanFull(),
Select::make('variant')->label('Farbe')->options(DashboardTile::VARIANTS)->default('brand')->visible($type('notice'))->native(false),
TextInput::make('url')->label('Link')->placeholder('https://… oder /seiten/…')->maxLength(2000),
Toggle::make('new_tab')->label('In neuem Tab öffnen')->inline(false),
Section::make('Anzeige')->columnSpanFull()->columns(3)->schema([
Toggle::make('is_active')->label('Aktiv')->default(true)->inline(false),
DateTimePicker::make('starts_at')->label('Ab')->native(false)->seconds(false)->displayFormat('d.m.Y H:i'),
DateTimePicker::make('ends_at')->label('Bis')->native(false)->seconds(false)->displayFormat('d.m.Y H:i')->after('starts_at'),
]),
AudienceSection::make('dashboard_tile', 'Wer die Kachel sieht. Leer lassen = alle.')->columnSpanFull(),
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
ImageColumn::make('image_path')->label('')->disk('uploads')->width(64)->height(40),
TextColumn::make('name')->label('Name')->weight('medium')->searchable(),
TextColumn::make('type')->label('Art')->formatStateUsing(fn (string $state) => DashboardTile::TYPES[$state] ?? $state),
TextColumn::make('area')->label('Bereich')->formatStateUsing(fn (string $state) => DashboardTile::AREAS[$state] ?? $state),
IconColumn::make('is_active')->label('Aktiv')->boolean(),
TextColumn::make('ends_at')->label('Bis')->dateTime('d.m.Y H:i')->placeholder('–'),
])
->recordActions([EditAction::make(), DeleteAction::make()])
->emptyStateHeading('Noch keine eigenen Kacheln')
->emptyStateDescription('Zum Beispiel ein verlinktes Bild in der Seitenleiste oder ein Hinweis ganz oben.');
}
public static function getPages(): array
{
return ['index' => ManageDashboardTiles::route('/')];
}
}