Files
laraundfelix/app/Domain/Communication/Inquiry.php
T
LarsandClaude Sonnet 5.5 fb479c1b01 Liefere das Anfrageformular je Anfragegrund aus und gib dem Widget Gründe, Formularführung und Präsentation
Das Widget Anfrage wählt statt eines Anfrage-Einstiegs mehrere Anfragegründe, jeder zeigt auf ein veröffentlichtes Formular
(optional mit vorgewähltem Anliegen). Der Besucher erhält genau das Formular seines Grundes: /anfrage/formular/{vorlage}
mit Grund in der Adresse, dasselbe Token, dieselbe Auswertung und Annahme. Ein Dialog (dialog-Element) und die Grundauswahl
als Karten oder Auswahlfeld kommen aus resources/js/inquiry-widget.js. Seiten mit einem Einstieg bleiben darstellbar.
Bereiche lassen sich wie Gruppen anzeigen oder ausblenden.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-27 22:29:31 +01:00

66 lines
2.1 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])));
}
/**
* Woher die Anfrage kam: der Anfrage-Einstieg (älterer Weg) oder das Formular, das das Widget „Anfrage“ eingebunden hat.
*/
public function channelTitle(): string
{
if ($this->entry !== null) {
return $this->entry->name;
}
$template = $this->templateVersion?->template;
return $template !== null ? 'Formular „'.$template->name.'“' : 'Formular gelöscht';
}
public function contactTitle(): string
{
return $this->contact_name ?: ($this->contact_email ?: 'Unbekannt');
}
}