location brought from model

This commit is contained in:
Cihan Şentürk
2021-09-03 12:53:35 +03:00
parent 414e405168
commit 6154ff31fd
10 changed files with 65 additions and 154 deletions

View File

@ -25,6 +25,13 @@ class Company extends Eloquent implements Ownable
protected $table = 'companies';
/**
* The accessors to append to the model's array form.
*
* @var array
*/
protected $appends = ['location'];
protected $dates = ['deleted_at'];
protected $fillable = ['domain', 'enabled', 'created_by'];
@ -446,6 +453,29 @@ class Company extends Eloquent implements Ownable
return $this->getMedia('company.logo')->last();
}
public function getLocationAttribute()
{
$location = [];
if (setting('company.city')) {
$location[] = setting('company.city');
}
if (setting('company.zip_code')) {
$location[] = setting('company.zip_code');
}
if (setting('company.state')) {
$location[] = setting('company.state');
}
if (setting('company.country')) {
$location[] = trans('countries.' . setting('company.country'));
}
return implode(', ', $location);
}
public function makeCurrent($force = false)
{
if (!$force && $this->isCurrent()) {