Files
laraundfelix/app/Domain/Communication/Inquiry.php
T
LarsandClaude Sonnet 5.5 2ee1fc9866 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>
2026-11-27 17:26:42 +01:00

52 lines
1.6 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace App\Domain\Communication;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
/**
* Eine eingegangene Anfrage. answers hält Bezeichnungen und Werte, wie sie der Besucher sah; sie bleiben auch nach
* einer Änderung der zentralen Konfiguration lesbar.
*/
class Inquiry extends Model
{
protected $fillable = [
'reference', 'entry_id', 'template_version_id', 'submission_token', 'issue_key', 'issue_label', 'subissue_key',
'subissue_label', 'contact_name', 'contact_email', 'contact_phone', 'organisation', 'message', 'answers',
'source_path', 'status', 'notified_at', 'notification_error',
];
protected function casts(): array
{
return ['answers' => 'array', 'status' => InquiryStatus::class, 'notified_at' => 'datetime'];
}
public function entry(): BelongsTo
{
return $this->belongsTo(InquiryEntry::class, 'entry_id');
}
public function templateVersion(): BelongsTo
{
return $this->belongsTo(InquiryTemplateVersion::class, 'template_version_id');
}
public function notes(): HasMany
{
return $this->hasMany(InquiryNote::class)->orderByDesc('created_at')->orderByDesc('id');
}
/** Lesbare Bezeichnung des Anliegens, mit Unteranliegen. */
public function issueTitle(): string
{
return trim(implode(' › ', array_filter([$this->issue_label, $this->subissue_label])));
}
public function contactTitle(): string
{
return $this->contact_name ?: ($this->contact_email ?: 'Unbekannt');
}
}