Enable editing of supplier products and listing services connected to them
This commit is contained in:
@@ -10,6 +10,8 @@ use App\Models\Product\Broadband as ProductBroadband;
|
||||
|
||||
class Broadband extends Type implements SupplierItem
|
||||
{
|
||||
protected const category_name = 'Broadband';
|
||||
|
||||
protected $casts = [
|
||||
'offpeak_start' => 'datetime:H:i',
|
||||
'offpeak_end' => 'datetime:H:i',
|
||||
@@ -35,16 +37,16 @@ class Broadband extends Type implements SupplierItem
|
||||
|
||||
/* INTERFACES */
|
||||
|
||||
public function types()
|
||||
{
|
||||
return $this->belongsToMany(ProductBroadband::class,$this->table,'id','id','id','supplier_item_id');
|
||||
}
|
||||
|
||||
public function getBillingIntervalAttribute(): int
|
||||
{
|
||||
return 1; // Monthly
|
||||
}
|
||||
|
||||
public function products()
|
||||
{
|
||||
return $this->hasMany(ProductBroadband::class,'supplier_item_id','id');
|
||||
}
|
||||
|
||||
/* METHODS */
|
||||
|
||||
/**
|
||||
@@ -156,14 +158,4 @@ class Broadband extends Type implements SupplierItem
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the Broadband Speed
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function speed(): string
|
||||
{
|
||||
return $this->speed;
|
||||
}
|
||||
}
|
@@ -8,6 +8,8 @@ use App\Models\TLD;
|
||||
|
||||
final class Domain extends Type implements SupplierItem
|
||||
{
|
||||
protected const category_name = 'Domain Name';
|
||||
|
||||
protected $table = 'supplier_domain';
|
||||
|
||||
/* INTERFACES */
|
||||
@@ -22,9 +24,9 @@ final class Domain extends Type implements SupplierItem
|
||||
return sprintf('%s: %s',$this->product_id,$this->tld->name);
|
||||
}
|
||||
|
||||
public function types()
|
||||
public function products()
|
||||
{
|
||||
return $this->belongsToMany(ProductDomain::class,$this->table,'id','id','id','supplier_item_id');
|
||||
return $this->hasMany(ProductDomain::class,'supplier_item_id','id');
|
||||
}
|
||||
|
||||
/* RELATIONS */
|
||||
|
@@ -7,6 +7,8 @@ use App\Models\Product\Email as ProductEmail;
|
||||
|
||||
final class Email extends Type implements SupplierItem
|
||||
{
|
||||
protected const category_name = 'Email Hosting';
|
||||
|
||||
protected $table = 'supplier_email';
|
||||
|
||||
/* INTERFACES */
|
||||
@@ -16,8 +18,8 @@ final class Email extends Type implements SupplierItem
|
||||
return 4; // Yearly
|
||||
}
|
||||
|
||||
public function types()
|
||||
public function products()
|
||||
{
|
||||
return $this->belongsToMany(ProductEmail::class,$this->table,'id','id','id','supplier_item_id');
|
||||
return $this->hasMany(ProductEmail::class,$this->table,'supplier_item_id','id');
|
||||
}
|
||||
}
|
@@ -4,4 +4,5 @@ namespace App\Models\Supplier;
|
||||
|
||||
class Ethernet extends Broadband
|
||||
{
|
||||
protected const category_name = 'Broadband Ethernet';
|
||||
}
|
@@ -7,17 +7,19 @@ use App\Models\Product\Generic as ProductGeneric;
|
||||
|
||||
final class Generic extends Type implements SupplierItem
|
||||
{
|
||||
protected const category_name = 'Generic';
|
||||
|
||||
protected $table = 'supplier_generic';
|
||||
|
||||
/* INTERFACES */
|
||||
|
||||
public function types()
|
||||
{
|
||||
return $this->belongsToMany(ProductGeneric::class,$this->table,'id','id','id','supplier_item_id');
|
||||
}
|
||||
|
||||
public function getBillingIntervalAttribute(): int
|
||||
{
|
||||
return 1; // Monthly
|
||||
}
|
||||
|
||||
public function products()
|
||||
{
|
||||
return $this->hasMany(ProductGeneric::class,'supplier_item_id','id');
|
||||
}
|
||||
}
|
@@ -4,4 +4,5 @@ namespace App\Models\Supplier;
|
||||
|
||||
class HSPA extends Broadband
|
||||
{
|
||||
protected const category_name = 'Mobile Broadband';
|
||||
}
|
@@ -7,17 +7,19 @@ use App\Models\Product\Host as ProductHost;
|
||||
|
||||
final class Host extends Type implements SupplierItem
|
||||
{
|
||||
protected const category_name = 'Web Hosting';
|
||||
|
||||
protected $table = 'supplier_host';
|
||||
|
||||
/* INTERFACES */
|
||||
|
||||
public function types()
|
||||
{
|
||||
return $this->belongsToMany(ProductHost::class,$this->table,'id','id','id','supplier_item_id');
|
||||
}
|
||||
|
||||
public function getBillingIntervalAttribute(): int
|
||||
{
|
||||
return 4; // Yearly
|
||||
}
|
||||
|
||||
public function products()
|
||||
{
|
||||
return $this->belongsToMany(ProductHost::class,'supplier_item_id','id');
|
||||
}
|
||||
}
|
@@ -7,17 +7,19 @@ use App\Models\Product\Phone as ProductVoip;
|
||||
|
||||
final class Phone extends Type implements SupplierItem
|
||||
{
|
||||
protected const category_name = 'Telephone';
|
||||
|
||||
protected $table = 'supplier_phone';
|
||||
|
||||
/* INTERFACES */
|
||||
|
||||
public function types()
|
||||
{
|
||||
return $this->belongsToMany(ProductVoip::class,$this->table,'id','id','id','supplier_item_id');
|
||||
}
|
||||
|
||||
public function getBillingIntervalAttribute(): int
|
||||
{
|
||||
return 1; // Monthly
|
||||
}
|
||||
|
||||
public function products()
|
||||
{
|
||||
return $this->hasMany(ProductVoip::class,'supplier_item_id','id');
|
||||
}
|
||||
}
|
@@ -7,17 +7,19 @@ use App\Models\Product\SSL as ProductSSL;
|
||||
|
||||
final class SSL extends Type implements SupplierItem
|
||||
{
|
||||
protected const category_name = 'SSL Certificate';
|
||||
|
||||
protected $table = 'supplier_ssl';
|
||||
|
||||
/* INTERFACES */
|
||||
|
||||
public function types()
|
||||
{
|
||||
return $this->belongsToMany(ProductSSL::class,$this->table,'id','id','id','supplier_item_id');
|
||||
}
|
||||
|
||||
public function getBillingIntervalAttribute(): int
|
||||
{
|
||||
return 4; // Yearly
|
||||
}
|
||||
|
||||
public function products()
|
||||
{
|
||||
return $this->belongsToMany(ProductSSL::class,'supplier_item_id','id');
|
||||
}
|
||||
}
|
@@ -27,6 +27,27 @@ abstract class Type extends Model
|
||||
return Tax::tax_calc($this->attributes['base_cost'],config('site')->taxes);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
final public function getCategoryAttribute(): string
|
||||
{
|
||||
return strtolower((new \ReflectionClass($this))->getShortName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a friendly name for this product, used for display
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
final public function getCategoryNameAttribute(): string
|
||||
{
|
||||
return static::category_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* This contract term is the highest of
|
||||
* + The defined contract_term
|
||||
|
Reference in New Issue
Block a user