2022-02-01 05:40:46 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models\Product;
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
use App\Models\Product;
|
|
|
|
use App\Traits\{OrderServiceOptions,SiteID};
|
|
|
|
|
2022-04-19 07:07:39 +00:00
|
|
|
/**
|
|
|
|
* @todo These tables have a base_cost/setup_cost/contract_term columns - how is that different to the supplier_tables?
|
2022-04-22 00:36:41 +00:00
|
|
|
* @todo Ensure our terminology is consistent - we have a "cost", we "charge" clients, and we have a "price" which is not official charges nor a cost.
|
2022-04-19 07:07:39 +00:00
|
|
|
*/
|
2022-02-01 05:40:46 +00:00
|
|
|
abstract class Type extends Model
|
|
|
|
{
|
|
|
|
use SiteID,OrderServiceOptions;
|
|
|
|
|
|
|
|
/* RELATIONS */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The product that sells this type
|
|
|
|
*
|
2023-03-15 04:34:28 +00:00
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\MorphMany
|
2022-02-01 05:40:46 +00:00
|
|
|
*/
|
2023-03-15 04:34:28 +00:00
|
|
|
public function products()
|
2022-02-01 05:40:46 +00:00
|
|
|
{
|
2023-03-15 04:34:28 +00:00
|
|
|
return $this->morphMany(Product::class, null,'model','model_id');
|
2022-02-01 05:40:46 +00:00
|
|
|
}
|
2022-06-12 01:21:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
2022-06-30 13:51:20 +00:00
|
|
|
* @deprecated - can this be replaced with product->supplied->category?
|
2022-06-12 01:21:20 +00:00
|
|
|
*/
|
|
|
|
final public function getCategoryAttribute(): string
|
|
|
|
{
|
2022-06-30 13:51:20 +00:00
|
|
|
abort(500,'use product->supplied->category_name');
|
2022-06-12 01:21:20 +00:00
|
|
|
return strtolower((new \ReflectionClass($this))->getShortName());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a friendly name for this product, used for display
|
|
|
|
*
|
|
|
|
* @return string
|
2022-06-30 13:51:20 +00:00
|
|
|
* @deprecated - can this be replaced with product->supplied->category_name
|
2022-06-12 01:21:20 +00:00
|
|
|
*/
|
|
|
|
final public function getCategoryNameAttribute(): string
|
|
|
|
{
|
2022-06-30 13:51:20 +00:00
|
|
|
abort(500,'use product->supplied->category_name');
|
2022-06-12 01:21:20 +00:00
|
|
|
return static::category_name;
|
|
|
|
}
|
2022-02-01 05:40:46 +00:00
|
|
|
}
|