Changed SITE_SETUP to SITE, using ->address instead of ->address(), added email_log, is now in views

This commit is contained in:
Deon George
2021-07-02 09:12:34 +10:00
parent c34da6bfb8
commit 34139bcbc2
19 changed files with 124 additions and 144 deletions

View File

@@ -149,6 +149,20 @@ class Account extends Model implements IDs
return $this->getUrlAdminAttribute();
}
/**
* Get the address for the account
*
* @return array
*/
public function getAddressAttribute(): array
{
return [
$this->address1,
$this->address2,
sprintf('%s %s %s',$this->city.(($this->state OR $this->zip) ? ',' : ''),$this->state,$this->zip)
];
}
/**
* Return the Account Unique Identifier
* @return string
@@ -219,36 +233,7 @@ class Account extends Model implements IDs
return sprintf('<a href="/u/account/view/%s">%s</a>',$this->id,$this->account_id);
}
/** FUNCTIONS **/
private function _address()
{
$return = [];
if ($this->address1)
array_push($return,$this->address1);
if ($this->address2)
array_push($return,$this->address2);
if ($this->city)
array_push($return,sprintf('%s %s %s',$this->city.(($this->state OR $this->zip) ? ',' : ''),$this->state,$this->zip));
if (! $return)
$return = ['No Address'];
return $return;
}
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());
}
}
/* GENERAL METHODS */
/**
* Get the due invoices on an account