Changed home screen to use account models instead of user model. Home screen now shows multiple accounts
This commit is contained in:
@@ -64,9 +64,15 @@ class Account extends Model implements IDs
|
||||
return $this->hasOneThrough(Group::class,AccountGroup::class,'account_id','id','id','group_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
* @todo This needs to be optimised, to only return outstanding invoices and invoices for a specific age (eg: 2 years worth)
|
||||
*/
|
||||
public function invoices()
|
||||
{
|
||||
return $this->hasMany(Invoice::class);
|
||||
return $this->hasMany(Invoice::class)
|
||||
->active()
|
||||
->with(['items.taxes','paymentitems.payment']);
|
||||
}
|
||||
|
||||
public function language()
|
||||
@@ -76,7 +82,9 @@ class Account extends Model implements IDs
|
||||
|
||||
public function payments()
|
||||
{
|
||||
return $this->hasMany(Payment::class);
|
||||
return $this->hasMany(Payment::class)
|
||||
->active()
|
||||
->with(['items']);
|
||||
}
|
||||
|
||||
public function providers()
|
||||
@@ -89,7 +97,8 @@ class Account extends Model implements IDs
|
||||
public function services($active=FALSE)
|
||||
{
|
||||
$query = $this->hasMany(Service::class,['account_id','site_id'],['id','site_id'])
|
||||
->withoutGlobalScope(SiteScope::class);
|
||||
->withoutGlobalScope(SiteScope::class)
|
||||
->with(['product.translate','invoice_items']);
|
||||
|
||||
return $active ? $query->active() : $query;
|
||||
}
|
||||
|
Reference in New Issue
Block a user