Lege das Datenmodell und den Anfrageservice der Kommunikationsverwaltung an

Anliegen, Feldkatalog, Feldgruppen, Anfragevorlagen mit unveränderlichen Fassungen,
Anfrage-Einstiege und eingegangene Anfragen. Eine gemeinsame Regelauswertung bedient
Besucher, Vorschau und Anfrageservice; Werte nicht mehr relevanter Felder werden verworfen,
Anliegen und Auswahlwerte serverseitig geprüft, doppeltes Absenden bleibt eine Anfrage.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Sonnet 5.5 committed 2026-11-27 17:26:42 +01:00
1 parent 9e2d64a4a9
commit 2ee1fc9866
30 files changed
+3380

No files matched your search

@@ -0,0 +1,61 @@
<?php
namespace App\Domain\Communication;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
/**
* Anfragevorlage: bearbeitbarer Entwurf (draft) und unveränderliche, veröffentlichte Fassungen.
*/
class InquiryTemplate extends Model
{
protected $fillable = ['key', 'name', 'description', 'draft', 'published_version_id', 'archived_at'];
protected function casts(): array
{
return ['draft' => 'array', 'archived_at' => 'datetime'];
}
public function versions(): HasMany
{
return $this->hasMany(InquiryTemplateVersion::class, 'template_id')->orderByDesc('version');
}
public function publishedVersion(): BelongsTo
{
return $this->belongsTo(InquiryTemplateVersion::class, 'published_version_id');
}
public function entries(): HasMany
{
return $this->hasMany(InquiryEntry::class, 'template_id');
}
public function isPublished(): bool
{
return $this->published_version_id !== null;
}
/** Ob der Entwurf von der veröffentlichten Fassung abweicht. */
public function hasUnpublishedChanges(): bool
{
$version = $this->publishedVersion;
return $version === null || FormJson::normalize($version->source) !== FormJson::normalize((array) $this->draft);
}
/**
* @return array<string, mixed>
*/
public static function emptyDraft(): array
{
return [
'texts' => [],
'issues' => [],
'steps' => [],
'rules' => [],
];
}
}