Finalize invoice creation and handling addresses.
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user