Product class optimisation

This commit is contained in:
2023-05-04 10:02:25 +10:00
parent a5238bfbdc
commit 0ac35c3d43
10 changed files with 31 additions and 85 deletions

View File

@@ -34,17 +34,8 @@ final class Broadband extends Type implements ProductItem
// The model that is referenced when this product is ordered
protected string $order_model = ServiceBroadband::class;
/* RELATIONS */
/**
* The offering supplied with this product
*
* @return \Illuminate\Database\Eloquent\Relations\HasOne
*/
public function supplied()
{
return $this->hasOne(SupplierBroadband::class,'id','supplier_item_id');
}
// The model that the supplier supplies
const SupplierModel = SupplierBroadband::class;
/* INTERFACES */

View File

@@ -31,17 +31,8 @@ final class Domain extends Type implements ProductItem
// The model that is referenced when this product is ordered
protected string $order_model = ServiceDomain::class;
/* RELATIONS */
/**
* The offering supplied with this product
*
* @return \Illuminate\Database\Eloquent\Relations\HasOne
*/
public function supplied()
{
return $this->hasOne(SupplierDomain::class,'id','supplier_item_id');
}
// The model that the supplier supplies
const SupplierModel = SupplierDomain::class;
/* INTERFACES */

View File

@@ -15,17 +15,8 @@ final class Email extends Type implements ProductItem
// The model that is referenced when this product is ordered
protected string $order_model = ServiceEmail::class;
/* RELATIONS */
/**
* The offering supplied with this product
*
* @return \Illuminate\Database\Eloquent\Relations\HasOne
*/
public function supplied()
{
return $this->hasOne(SupplierEmail::class,'id','supplier_item_id');
}
// The model that the supplier supplies
const SupplierModel = SupplierEmail::class;
/* INTERFACES */

View File

@@ -15,17 +15,8 @@ final class Generic extends Type implements ProductItem
// The model that is referenced when this product is ordered
protected string $order_model = ServiceGeneric::class;
/* RELATIONS */
/**
* The offering supplied with this product
*
* @return \Illuminate\Database\Eloquent\Relations\HasOne
*/
public function supplied()
{
return $this->hasOne(SupplierGeneric::class,'id','supplier_item_id');
}
// The model that the supplier supplies
const SupplierModel = SupplierGeneric::class;
/* INTERFACES */

View File

@@ -15,17 +15,8 @@ final class Host extends Type implements ProductItem
// The model that is referenced when this product is ordered
protected string $order_model = ServiceHost::class;
/* RELATIONS */
/**
* The offering supplied with this product
*
* @return \Illuminate\Database\Eloquent\Relations\HasOne
*/
public function supplied()
{
return $this->hasOne(SupplierHost::class,'id','supplier_item_id');
}
// The model that the supplier supplies
const SupplierModel = SupplierHost::class;
/* INTERFACES */

View File

@@ -42,17 +42,8 @@ final class Phone extends Type implements ProductItem
// The model that is referenced when this product is ordered
protected string $order_model = ServicePhone::class;
/* RELATIONS */
/**
* The offering supplied with this product
*
* @return \Illuminate\Database\Eloquent\Relations\HasOne
*/
public function supplied()
{
return $this->hasOne(SupplierPhone::class,'id','supplier_item_id');
}
// The model that the supplier supplies
const SupplierModel = SupplierPhone::class;
/* INTERFACES */

View File

@@ -15,17 +15,8 @@ final class SSL extends Type implements ProductItem
// The model that is referenced when this product is ordered
protected string $order_model = ServiceSSL::class;
/* RELATIONS */
/**
* The offering supplied with this product
*
* @return \Illuminate\Database\Eloquent\Relations\HasOne
*/
public function supplied()
{
return $this->hasOne(SupplierSSL::class,'id','supplier_item_id');
}
// The model that the supplier supplies
const SupplierModel = SupplierSSL::class;
/* INTERFACES */

View File

@@ -27,6 +27,16 @@ abstract class Type extends Model
return $this->morphMany(Product::class, null,'model','model_id');
}
/**
* The offering supplied with this product
*
* @return \Illuminate\Database\Eloquent\Relations\HasOne
*/
public function supplied()
{
return $this->hasOne(static::SupplierModel,'id','supplier_item_id');
}
/**
* This will return the category of the product (eg: domain, hosting, etc) which is the basis for all
* other logic of these types.