Finalize invoice creation and handling addresses.

This commit is contained in:
2025-01-11 10:42:53 +01:00
parent 2b3c93a8b6
commit a05d23be7b
6 changed files with 131 additions and 39 deletions

View File

@@ -29,12 +29,34 @@ class Customer extends Model
*/
protected $appends = [
'created',
'street',
'city'
];
/**
* Deliver the customer's address as street directly with the model.
*/
public function getStreetAttribute(): string
{
if (is_null($this->address)) {
return '';
}
return $this->address->address;
}
/**
* Deliver the customer's address as city directly with the model.
*/
public function getCityAttribute(): string
{
if (is_null($this->address)) {
return '';
}
return $this->address->city;
}
/**
* Get the created_at attribute in local time format.
*
* @return string
*/
public function getCreatedAttribute(): string
{
@@ -43,8 +65,6 @@ class Customer extends Model
/**
* Get the invoice address.
*
* @return HasOne
*/
public function address(): HasOne
{
@@ -56,8 +76,6 @@ class Customer extends Model
/**
* Get the delivery address.
*
* @return HasOne
*/
public function delivery(): HasOne
{
@@ -69,8 +87,6 @@ class Customer extends Model
/**
* Get all customer's addresses.
*
* @return HasMany
*/
public function addresses(): HasMany
{