osb/app/Models/Product/Type.php

46 lines
1.0 KiB
PHP
Raw Normal View History

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?
* @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
*
* @return \Illuminate\Database\Eloquent\Relations\MorphMany
2022-02-01 05:40:46 +00:00
*/
final public function products()
2022-02-01 05:40:46 +00:00
{
return $this->morphMany(Product::class, null,'model','model_id');
2022-02-01 05:40:46 +00:00
}
2023-05-04 00:02:25 +00:00
/**
* The offering supplied with this product
*
* @return \Illuminate\Database\Eloquent\Relations\HasOne
*/
final public function supplied()
2023-05-04 00:02:25 +00:00
{
return $this->hasOne(static::SupplierModel,'id','supplier_item_id');
}
/* METHODs */
final function normalizeBillingInterval(): int
{
return static::DefaultBill;
}
2022-02-01 05:40:46 +00:00
}