Optimise users home page
This commit is contained in:
@@ -121,7 +121,8 @@ class User extends Authenticatable
|
||||
*/
|
||||
public function invoices()
|
||||
{
|
||||
return $this->hasManyThrough(Invoice::class,Account::class);
|
||||
return $this->hasManyThrough(Invoice::class,Account::class)
|
||||
->active();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -141,7 +142,8 @@ class User extends Authenticatable
|
||||
*/
|
||||
public function services()
|
||||
{
|
||||
return $this->hasManyThrough(Service::class,Account::class);
|
||||
return $this->hasManyThrough(Service::class,Account::class)
|
||||
->active();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -241,20 +243,6 @@ class User extends Authenticatable
|
||||
->reverse();
|
||||
}
|
||||
|
||||
/**
|
||||
* The users active services
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getServicesActiveAttribute()
|
||||
{
|
||||
return $this->services
|
||||
->filter(function($item)
|
||||
{
|
||||
return $item->isActive();
|
||||
});
|
||||
}
|
||||
|
||||
public function getServicesCountHtmlAttribute()
|
||||
{
|
||||
return sprintf('%s <small>/%s</small>',$this->services->where('active',TRUE)->count(),$this->services->count());
|
||||
@@ -523,7 +511,7 @@ class User extends Authenticatable
|
||||
DB::raw('ROUND(ab_invoice_item_tax.amount,2) AS tax'),
|
||||
|
||||
])
|
||||
->join('ab_invoice_item_tax',['ab_invoice_item_tax.invoice_item_id'=>'ab_invoice_item.id'])
|
||||
->leftjoin('ab_invoice_item_tax',['ab_invoice_item_tax.invoice_item_id'=>'ab_invoice_item.id'])
|
||||
->where('active',TRUE);
|
||||
}
|
||||
|
||||
@@ -548,6 +536,7 @@ class User extends Authenticatable
|
||||
* Return an SQL query that will summarise invoices with payments
|
||||
*
|
||||
* @return \Illuminate\Database\Query\Builder
|
||||
* @todo change this to just return outstanding invoices as a collection.
|
||||
*/
|
||||
public function query_invoice_summary()
|
||||
{
|
||||
|
Reference in New Issue
Block a user