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:
1 parent
9e2d64a4a9
commit
2ee1fc9866
30 files changed
+3380
No files matched your search
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Communication;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
/**
|
||||
* Anfrage-Einstieg: die veröffentlichbare Nutzungsvariante einer Anfragevorlage. config ist der Entwurf,
|
||||
* published_config der wirksame Stand.
|
||||
*/
|
||||
class InquiryEntry extends Model
|
||||
{
|
||||
protected $fillable = ['key', 'name', 'template_id', 'config', 'published_config', 'published_at', 'archived_at'];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return ['config' => 'array', 'published_config' => 'array', 'published_at' => 'datetime', 'archived_at' => 'datetime'];
|
||||
}
|
||||
|
||||
public function template(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(InquiryTemplate::class, 'template_id');
|
||||
}
|
||||
|
||||
public function inquiries(): HasMany
|
||||
{
|
||||
return $this->hasMany(Inquiry::class, 'entry_id');
|
||||
}
|
||||
|
||||
/** Einstiege, die Besuchern ausgeliefert werden können (Vorlage zusätzlich in isLive() prüfen). */
|
||||
public function scopeLive(Builder $query): Builder
|
||||
{
|
||||
return $query->whereNotNull('published_at')->whereNull('archived_at')->whereNotNull('published_config');
|
||||
}
|
||||
|
||||
public function isLive(): bool
|
||||
{
|
||||
return $this->published_at !== null && $this->archived_at === null && $this->published_config !== null
|
||||
&& $this->template?->published_version_id !== null && $this->template->archived_at === null;
|
||||
}
|
||||
|
||||
public function hasUnpublishedChanges(): bool
|
||||
{
|
||||
return $this->published_config === null || FormJson::normalize($this->published_config) !== FormJson::normalize((array) $this->config);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public static function emptyConfig(): array
|
||||
{
|
||||
return [
|
||||
'mode' => 'compact',
|
||||
'open' => 'inline',
|
||||
'allowed_issues' => [],
|
||||
'allowed_subissues' => [],
|
||||
'defaults' => [],
|
||||
'texts' => [],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user