Fix countries for documents #1p66u4u

This commit is contained in:
Cüneyt Şentürk
2021-11-08 02:40:40 +03:00
parent 4f1146dc33
commit d9d0e09e3a
15 changed files with 112 additions and 5 deletions

View File

@ -200,7 +200,6 @@ class Contact extends Model
return $amount;
}
public function getLocationAttribute()
{
$location = [];

View File

@ -26,7 +26,7 @@ class Document extends Model
protected $table = 'documents';
protected $appends = ['attachment', 'amount_without_tax', 'discount', 'paid', 'received_at', 'status_label', 'sent_at', 'reconciled'];
protected $appends = ['attachment', 'amount_without_tax', 'discount', 'paid', 'received_at', 'status_label', 'sent_at', 'reconciled', 'contact_location'];
protected $dates = ['deleted_at', 'issued_at', 'due_at'];
@ -48,6 +48,10 @@ class Document extends Model
'contact_tax_number',
'contact_phone',
'contact_address',
'contact_country',
'contact_state',
'contact_zip_code',
'contact_city',
'notes',
'footer',
'parent_id',
@ -397,6 +401,29 @@ class Document extends Model
return $value ?: 'sales.invoices.print_' . setting('invoice.template');
}
public function getContactLocationAttribute()
{
$location = [];
if ($this->contact_city) {
$location[] = $this->contact_city;
}
if ($this->contact_zip_code) {
$location[] = $this->contact_zip_code;
}
if ($this->contact_state) {
$location[] = $this->contact_state;
}
if ($this->contact_country) {
$location[] = trans('countries.' . $this->contact_country);
}
return implode(', ', $location);
}
protected static function newFactory(): Factory
{
return DocumentFactory::new();