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

View File

@@ -139,7 +139,7 @@ class Invoice extends Model implements IDs
// @todo Move this to a site configuration
public function getInvoiceTextAttribute()
{
return sprintf('Thank you for using %s for your Internet Services.',config('SITE_SETUP')->site_name);
return sprintf('Thank you for using %s for your Internet Services.',config('SITE')->site_name);
}
/**

View File

@@ -100,7 +100,7 @@ class Product extends Model implements IDs
private function getDefaultLanguage()
{
return config('SITE_SETUP')->language;
return config('SITE')->language;
}
public function getDescriptionAttribute()

View File

@@ -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());
}
}
}

View File

@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
use Leenooks\Traits\CompositeKeys;
class SiteDetails extends Model
class SiteDetail extends Model
{
use CompositeKeys;
@@ -189,6 +189,7 @@ class SiteDetails extends Model
['title'=>'Title 3','text'=>'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.','icon'=>'fa fa-check red','image'=>'/image/generic/200/100/999'],
],
*/
'email_logo'=>route('image',['width'=>150,'height'=>20,'color'=>'eee']),
'site_address1' => 'Address line 1',
'site_address2' => 'Address line 2',
'site_description'=>'Example Site',