Moved out rejected orders

This commit is contained in:
Deon George
2018-11-21 13:46:16 +11:00
parent aeacb726dd
commit 72fcdab84e
8 changed files with 139 additions and 4 deletions

View File

@@ -49,6 +49,7 @@ class Service extends Model
private $inactive_status = [
'CANCELLED',
'ORDER-REJECTED',
];
public function account()
@@ -96,6 +97,19 @@ class Service extends Model
return $this->belongsTo(Product::class);
}
/**
* Find inactive services.
*
* @param $query
* @return mixed
*/
public function scopeInActive($query)
{
return $query->where(function () use ($query) {
return $query->where('active',FALSE)->orWhereIn('order_status',$this->inactive_status);
});
}
/**
* Only query active categories
*/
@@ -118,7 +132,8 @@ class Service extends Model
public function getCategoryAttribute()
{
return $this->product->category;
// @todo: All services should be linked to a product. This might require data cleaning for old services not linked to a product.
return is_object($this->product) ? $this->product->category : 'Unknown Product';
}
public function getNameAttribute()
@@ -136,7 +151,8 @@ class Service extends Model
public function getProductNameAttribute()
{
return $this->product->name($this->account->language);
// @todo: All services should be linked to a product. This might require data cleaning for old services not linked to a product.
return is_object($this->product) ? $this->product->name($this->account->language) : 'Unknown Product';
}
public function getServiceExpireAttribute()
@@ -197,6 +213,10 @@ class Service extends Model
*/
private function ServicePlugin()
{
// @todo: All services should be linked to a product. This might require data cleaning for old services not linked to a product.
if (! is_object($this->product))
return NULL;
switch ($this->product->prod_plugin_file)
{
case 'ADSL': return $this->service_adsl;