close #2561 Fixed: Countries prefix flaw

This commit is contained in:
Cüneyt Şentürk 2022-08-10 11:16:30 +03:00
parent ddfdfdcb8e
commit 0fd7b4e0c9
8 changed files with 35 additions and 9 deletions

View File

@ -16,10 +16,16 @@ class Bills extends Export implements WithColumnFormatting
public function map($model): array
{
$country = null;
if ($model->contact_country && array_key_exists($model->contact_country, trans('countries'))) {
$country = trans('countries.' . $model->contact_country);
}
$model->category_name = $model->category->name;
$model->bill_number = $model->document_number;
$model->billed_at = $model->issued_at;
$model->contact_country = ($model->contact_country) ? trans('countries.' . $model->contact_country) : null;
$model->contact_country = $country;
return parent::map($model);
}

View File

@ -14,7 +14,13 @@ class Vendors extends Export
public function map($model): array
{
$model->country = ($model->country) ? trans('countries.' . $model->country) : null;
$country = null;
if ($model->country && array_key_exists($model->country, trans('countries'))) {
$country = trans('countries.' . $model->country);
}
$model->country = $country;
return parent::map($model);
}

View File

@ -14,7 +14,13 @@ class Customers extends Export
public function map($model): array
{
$model->country = ($model->country) ? trans('countries.' . $model->country) : null;
$country = null;
if ($model->country && array_key_exists($model->country, trans('countries'))) {
$country = trans('countries.' . $model->country);
}
$model->country = $country;
return parent::map($model);
}

View File

@ -16,10 +16,16 @@ class Invoices extends Export implements WithColumnFormatting
public function map($model): array
{
$country = null;
if ($model->contact_country && array_key_exists($model->contact_country, trans('countries'))) {
$country = trans('countries.' . $model->contact_country);
}
$model->category_name = $model->category->name;
$model->invoice_number = $model->document_number;
$model->invoiced_at = $model->issued_at;
$model->contact_country = ($model->contact_country) ? trans('countries.' . $model->contact_country) : null;
$model->contact_country = $country;
return parent::map($model);
}

View File

@ -526,8 +526,10 @@ class Company extends Eloquent implements Ownable
$location[] = setting('company.state');
}
if (setting('company.country')) {
$location[] = trans('countries.' . setting('company.country'));
$country = setting('company.country');
if ($country && in_array($country, trans('countries'))) {
$location[] = trans('countries.' . $country);
}
return implode(', ', $location);

View File

@ -254,7 +254,7 @@ class Contact extends Model
$location[] = $this->state;
}
if ($this->country) {
if ($this->country && in_array($this->country, trans('countries'))) {
$location[] = trans('countries.' . $this->country);
}

View File

@ -463,7 +463,7 @@ class Document extends Model
$location[] = $this->contact_state;
}
if ($this->contact_country) {
if ($this->contact_country && in_array($this->contact_country, trans('countries'))) {
$location[] = trans('countries.' . $this->contact_country);
}

View File

@ -37,7 +37,7 @@ class Country extends Component
*/
public function render()
{
if (! empty($this->code)) {
if (! empty($this->code) && in_array($this->code, trans('countries'))) {
$this->country = trans('countries.' . $this->code);
}