Move category/category_name product::class methods into __get(), no functional changes
This commit is contained in:
@@ -77,6 +77,10 @@ class Product extends Model implements IDs
|
||||
return match ($key) {
|
||||
'base_cost' => round($this->supplied->base_cost,2)*Invoice::billing_change($this->type->billing_interval,$this->billing_interval) ?: 0,
|
||||
|
||||
'category' => $this->supplied->category,
|
||||
'category_lc' => strtolower($this->category),
|
||||
'category_name' => $this->supplied->category_name,
|
||||
|
||||
default => parent::__get($key),
|
||||
};
|
||||
}
|
||||
@@ -181,29 +185,6 @@ class Product extends Model implements IDs
|
||||
return max($this->price_recur_default,$this->type->billing_interval);
|
||||
}
|
||||
|
||||
/**
|
||||
* This will return the category of the product (eg: domain, webhosting, etc) which is the basis for all
|
||||
* other logic of these types.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCategoryAttribute(): string
|
||||
{
|
||||
return strtolower(Str::studly($this->category_name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the type of service is provided. eg: Broadband, Phone.
|
||||
* This will return the category of the product (eg: domain, hosting, etc) which is the basis for all
|
||||
* other logic of these types.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCategoryNameAttribute(): string
|
||||
{
|
||||
return $this->supplied->category_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* How long must this product be purchased for as a service.
|
||||
*
|
||||
|
Reference in New Issue
Block a user