Using morphTo() on services, added Ezypay payment Import

This commit is contained in:
Deon George
2019-06-07 16:54:27 +10:00
parent 41d6a07196
commit 253eb55c19
33 changed files with 11398 additions and 183 deletions

View File

@@ -16,13 +16,14 @@ class Account extends Model
protected $appends = [
'active_display',
'name',
'services_count_html',
'switch_url',
];
protected $visible = [
'id',
'company',
'active_display',
'name',
'services_count_html',
'switch_url',
];
@@ -40,6 +41,11 @@ class Account extends Model
return $this->belongsTo(Language::class);
}
public function payments()
{
return $this->hasMany(Payment::class);
}
public function services()
{
return $this->hasMany(Service::class);
@@ -55,11 +61,6 @@ class Account extends Model
return sprintf('<span class="btn-sm btn-block btn-%s text-center">%s</span>',$this->active ? 'success' : 'danger',$this->active ? 'Active' : 'Inactive');
}
public function getCompanyAttribute($value)
{
return $value ? $value : $this->user->SurFirstName;
}
public function getAccountIdAttribute()
{
return sprintf('%02s-%04s',$this->site_id,$this->id);
@@ -70,6 +71,11 @@ class Account extends Model
return sprintf('<a href="/r/account/view/%s">%s</a>',$this->id,$this->account_id);
}
public function getNameAttribute()
{
return $this->company ?: $this->user->SurFirstName;
}
public function getServicesCountHtmlAttribute()
{
return sprintf('%s <small>/%s</small>',$this->services->where('active',TRUE)->count(),$this->services->count());