Using morphTo() on services, added Ezypay payment Import
This commit is contained in:
@@ -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());
|
||||
|
Reference in New Issue
Block a user