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
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:
parent
435960725d
commit
ee8dde93c0
262 changed files with 2385 additions and 692 deletions
94
app/Models/DashboardTile.php
Normal file
94
app/Models/DashboardTile.php
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Pagebuilder\Field;
|
||||
use App\Support\Permissions\Audiences;
|
||||
use App\Support\RichText;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
/**
|
||||
* Eigene Kachel auf der Startseite („Administration → Portal → Startseite“).
|
||||
*/
|
||||
#[Fillable(['name', 'type', 'area', 'title', 'image_path', 'url', 'new_tab', 'alt', 'body', 'variant', 'is_active', 'starts_at', 'ends_at'])]
|
||||
class DashboardTile extends Model
|
||||
{
|
||||
public const TYPES = [
|
||||
'image' => 'Bild mit Link',
|
||||
'text' => 'Text',
|
||||
'notice' => 'Hinweis',
|
||||
];
|
||||
|
||||
public const AREAS = [
|
||||
'aside' => 'Seitenleiste (rechts)',
|
||||
'main' => 'Hauptspalte (breit)',
|
||||
'top' => 'Ganz oben (volle Breite)',
|
||||
];
|
||||
|
||||
public const VARIANTS = [
|
||||
'brand' => 'Markenfarbe',
|
||||
'info' => 'Info (blau)',
|
||||
'success' => 'Erfolg (grün)',
|
||||
'warning' => 'Warnung (rot)',
|
||||
'neutral' => 'Neutral (grau)',
|
||||
];
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::saving(function (DashboardTile $tile) {
|
||||
$tile->url = filled($tile->url) ? (Field::safeUrl($tile->url) ?: null) : null;
|
||||
|
||||
if ($tile->isDirty('body')) {
|
||||
$tile->body_html = app(RichText::class)->toSafeHtml($tile->body);
|
||||
}
|
||||
});
|
||||
|
||||
static::deleted(fn (DashboardTile $tile) => $tile->image_path && Storage::disk('uploads')->delete($tile->image_path));
|
||||
}
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return ['new_tab' => 'boolean', 'is_active' => 'boolean', 'starts_at' => 'datetime', 'ends_at' => 'datetime'];
|
||||
}
|
||||
|
||||
public function widgetKey(): string
|
||||
{
|
||||
return 'tile.'.$this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Aktiv, im Zeitraum und für die Person sichtbar.
|
||||
*
|
||||
* @param Builder<DashboardTile> $query
|
||||
*/
|
||||
public function scopeVisibleTo(Builder $query, User $user): void
|
||||
{
|
||||
$query->where('is_active', true)
|
||||
->where(fn ($q) => $q->whereNull('starts_at')->orWhere('starts_at', '<=', now()))
|
||||
->where(fn ($q) => $q->whereNull('ends_at')->orWhere('ends_at', '>', now()));
|
||||
|
||||
Audiences::constrain($query, 'dashboard_tile', 'dashboard_tiles.id', $user);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toWidgetProps(): array
|
||||
{
|
||||
return [
|
||||
'tile' => [
|
||||
'type' => $this->type,
|
||||
'title' => $this->title,
|
||||
'image_url' => $this->image_path ? Storage::disk('uploads')->url($this->image_path) : null,
|
||||
'url' => $this->url,
|
||||
'new_tab' => $this->new_tab,
|
||||
'alt' => $this->alt ?: '',
|
||||
'html' => $this->body_html,
|
||||
'variant' => $this->variant ?: 'brand',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue