location brought from model
This commit is contained in:
@@ -31,10 +31,6 @@ abstract class DocumentTemplate extends Base
|
||||
|
||||
public $logo;
|
||||
|
||||
public $companyLocation;
|
||||
|
||||
public $contactLocation;
|
||||
|
||||
public $backgroundColor;
|
||||
|
||||
public $hideFooter;
|
||||
@@ -127,7 +123,7 @@ abstract class DocumentTemplate extends Base
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
$type, $document, $item = false, $documentTemplate = '', $logo = '', $backgroundColor = '', $companyLocation = '', $contactLocation = '',
|
||||
$type, $document, $item = false, $documentTemplate = '', $logo = '', $backgroundColor = '',
|
||||
bool $hideFooter = false, bool $hideCompanyLogo = false, bool $hideCompanyDetails = false,
|
||||
bool $hideCompanyName = false, bool $hideCompanyAddress = false, bool $hideCompanyTaxNumber = false, bool $hideCompanyPhone = false, bool $hideCompanyEmail = false, bool $hideContactInfo = false,
|
||||
bool $hideContactName = false, bool $hideContactAddress = false, bool $hideContactTaxNumber = false, bool $hideContactPhone = false, bool $hideContactEmail = false,
|
||||
@@ -143,8 +139,6 @@ abstract class DocumentTemplate extends Base
|
||||
$this->documentTemplate = $this->getDocumentTemplate($type, $documentTemplate);
|
||||
$this->logo = $this->getLogo($logo);
|
||||
$this->backgroundColor = $this->getBackgroundColor($type, $backgroundColor);
|
||||
$this->companyLocation = $this->getCompanyLocation();
|
||||
$this->contactLocation = $this->getContactLocation($document);
|
||||
|
||||
$this->hideFooter = $hideFooter;
|
||||
$this->hideCompanyLogo = $hideCompanyLogo;
|
||||
@@ -652,50 +646,4 @@ abstract class DocumentTemplate extends Base
|
||||
// @todo what return value invoice or always false??
|
||||
return setting('invoice.hide_amount', $hideAmount);
|
||||
}
|
||||
|
||||
protected function getCompanyLocation()
|
||||
{
|
||||
$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);
|
||||
}
|
||||
|
||||
protected function getContactLocation($document)
|
||||
{
|
||||
$location = [];
|
||||
|
||||
if ($document->contact->city) {
|
||||
$location[] = $document->contact->city;
|
||||
}
|
||||
|
||||
if ($document->contact->zip_code) {
|
||||
$location[] = $document->contact->zip_code;
|
||||
}
|
||||
|
||||
if ($document->contact->state) {
|
||||
$location[] = $document->contact->state;
|
||||
}
|
||||
|
||||
if ($document->contact->country) {
|
||||
$location[] = trans('countries.' . $document->contact->country);
|
||||
}
|
||||
|
||||
return implode(', ', $location);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
@@ -19,6 +19,13 @@ class Contact extends Model
|
||||
|
||||
protected $table = 'contacts';
|
||||
|
||||
/**
|
||||
* The accessors to append to the model's array form.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $appends = ['location'];
|
||||
|
||||
/**
|
||||
* Attributes that should be mass-assignable.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user