*/ public function user(): BelongsTo { return $this->belongsTo(User::class); } /** * Ist die Adresse vollständig genug für eine Rechnung bzw. Buchung? * Maßgeblich: Empfänger (Name), Straße, PLZ, Ort und Land. * * @var list */ public const REQUIRED_FIELDS = ['name', 'address1', 'postal_code', 'city', 'country_code']; public function isComplete(): bool { return collect(self::REQUIRED_FIELDS) ->every(fn (string $field): bool => filled($this->{$field})); } /** * Anteil der ausgefüllten Pflichtfelder in Prozent (0–100) — für die * Fortschritts-Anzeige im Dashboard. */ public function completenessPercent(): int { $filled = collect(self::REQUIRED_FIELDS) ->filter(fn (string $field): bool => filled($this->{$field})) ->count(); return (int) round(($filled / count(self::REQUIRED_FIELDS)) * 100); } }