*/ protected $fillable = [ 'name', 'email', ]; /** * The attributes that are appended with attribute getters. * * @var string[] */ protected $appends = [ 'created', ]; /** * Get the created_at attribute in local time format. * * @return string */ public function getCreatedAttribute(): string { return $this->created_at->format('d.m.Y'); } /** * Get the invoice address. * * @return HasOne */ public function address(): HasOne { return $this->hasOne(Address::class)->ofMany([], function (Builder $query) { $query->where('is_address', '=', true); }); } /** * Get the delivery address. * * @return HasOne */ public function delivery(): HasOne { return $this->hasOne(Address::class)->ofMany([], function (Builder $query) { $query->where('is_delivery', '=', true); }); } /** * Get all customer's addresses. * * @return HasMany */ public function addresses(): HasMany { return $this->hasMany(Address::class); } }