Changed SITE_SETUP to SITE, using ->address instead of ->address(), added email_log, is now in views
This commit is contained in:
@@ -31,7 +31,7 @@ class Site extends Model
|
||||
|
||||
public function details()
|
||||
{
|
||||
return $this->hasMany(SiteDetails::class,NULL,'site_id');
|
||||
return $this->hasMany(SiteDetail::class,NULL,'site_id');
|
||||
}
|
||||
|
||||
public function language()
|
||||
@@ -60,7 +60,7 @@ class Site extends Model
|
||||
return $x;
|
||||
|
||||
if (is_null($details))
|
||||
$details = new SiteDetails;
|
||||
$details = new SiteDetail;
|
||||
|
||||
// Get a default value for this key
|
||||
$value = $details->sample($key);
|
||||
@@ -88,6 +88,15 @@ class Site extends Model
|
||||
return NULL;
|
||||
}
|
||||
|
||||
public function getAddressAttribute(): array
|
||||
{
|
||||
return [
|
||||
$this->site_address1,
|
||||
$this->site_address2,
|
||||
sprintf('%s %s %s',$this->site_city.(($this->site_state OR $this->site_postcode) ? ',' : ''),$this->site_state,$this->site_postcode)
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the path to the mail logo, so it can be displayed.
|
||||
*
|
||||
@@ -108,35 +117,4 @@ class Site extends Model
|
||||
{
|
||||
return (($x=$this->detail_item('site_logo')) !== NULL) ? '/storage/'.$x : '/image/generic/150/20/fff';
|
||||
}
|
||||
|
||||
// @todo - To optimize
|
||||
private function _address()
|
||||
{
|
||||
$return = [];
|
||||
|
||||
if ($this->site_address1)
|
||||
array_push($return,$this->site_address1);
|
||||
if ($this->site_address2)
|
||||
array_push($return,$this->site_address2);
|
||||
if ($this->site_city)
|
||||
array_push($return,sprintf('%s %s %s',$this->site_city.(($this->site_state OR $this->site_postcode) ? ',' : ''),$this->site_state,$this->site_postcode));
|
||||
|
||||
if (! $return)
|
||||
$return = ['No Address'];
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
// @todo - To optimize
|
||||
public function address($type='plain')
|
||||
{
|
||||
switch ($type)
|
||||
{
|
||||
case 'html' : return join('<br>',$this->_address());
|
||||
case 'newline': return join("\m",$this->_address());
|
||||
|
||||
default:
|
||||
return join("\n",$this->_address());
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user