presseportale/app/Models/BillingAddress.php
2026-06-12 14:36:18 +00:00

46 lines
1 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class BillingAddress extends Model
{
use HasFactory;
protected $fillable = [
'user_id',
'salutation_key',
'title',
'company',
'first_name',
'last_name',
'name',
'address1',
'address2',
'postal_code',
'city',
'country_code',
'vat_id',
];
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.
*/
public function isComplete(): bool
{
return filled($this->name)
&& filled($this->address1)
&& filled($this->postal_code)
&& filled($this->city)
&& filled($this->country_code);
}
}