More works on products

This commit is contained in:
Deon George
2022-02-01 16:40:46 +11:00
parent 1e9f15b40f
commit b9b4416737
36 changed files with 952 additions and 312 deletions

View File

@@ -4,18 +4,13 @@ namespace App\Models\Product;
use Illuminate\Support\Collection;
use App\Interfaces\ProductSupplier;
use App\Models\Base\ProductType;
use App\Models\{Product,Supplier};
use App\Interfaces\ProductItem;
use App\Models\Supplier;
use App\Models\Service\Broadband as ServiceBroadband;
use App\Models\Supplier\Broadband as SupplierBroadband;
use App\Traits\{OrderServiceOptions,SiteID};
class Broadband extends ProductType implements ProductSupplier
final class Broadband extends Type implements ProductItem
{
use SiteID;
use OrderServiceOptions;
protected $table = 'product_broadband';
// Information required during the order process
@@ -34,20 +29,11 @@ class Broadband extends ProductType implements ProductSupplier
],
];
// The model that is referenced when this product is ordered
protected string $order_model = ServiceBroadband::class;
/* RELATIONS */
/**
* The product that sells this type
*
* @return \Illuminate\Database\Eloquent\Relations\MorphOne
*/
public function product()
{
return $this->morphOne(Product::class, null,'model','model_id');
}
/**
* The offering supplied with this product
*
@@ -123,6 +109,7 @@ class Broadband extends ProductType implements ProductSupplier
*
* @return string
*/
// @todo To check
public function allowance_string(): string
{
$result = '';

View File

@@ -4,14 +4,30 @@ namespace App\Models\Product;
use Illuminate\Support\Collection;
use App\Interfaces\ProductSupplier;
use App\Models\Base\ProductType;
use App\Traits\NextKey;
use App\Interfaces\ProductItem;
use App\Models\Service\Domain as ServiceDomain;
use App\Models\Supplier\Domain as SupplierDomain;
class Domain extends ProductType implements ProductSupplier
final class Domain extends Type implements ProductItem
{
use NextKey;
const RECORD_ID = '';
protected $table = 'product_domain';
// 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_domain_id');
}
/* INTERFACES */
public function allowance(): Collection
{

View File

@@ -2,10 +2,33 @@
namespace App\Models\Product;
use App\Models\Base\ProductType;
use Illuminate\Support\Collection;
class Generic extends ProductType
use App\Interfaces\ProductItem;
use App\Models\Service\Generic as ServiceGeneric;
use App\Models\Supplier\Generic as SupplierGeneric;
final class Generic extends Type implements ProductItem
{
protected $table = 'product_generic';
// 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_generic_id');
}
/* INTERFACES */
public function getContractTermAttribute(): int
{
return 0;
@@ -20,4 +43,24 @@ class Generic extends ProductType
{
return FALSE;
}
public function allowance(): Collection
{
// TODO: Implement allowance() method.
}
public function allowance_string(): string
{
// TODO: Implement allowance_string() method.
}
public function getCostAttribute(): float
{
// TODO: Implement getCostAttribute() method.
}
public function getSupplierAttribute()
{
// TODO: Implement getSupplierAttribute() method.
}
}

View File

@@ -2,13 +2,32 @@
namespace App\Models\Product;
use App\Models\Base\ProductType;
use App\Traits\NextKey;
use Illuminate\Support\Collection;
class Host extends ProductType
use App\Interfaces\ProductItem;
use App\Models\Service\Host as ServiceHost;
use App\Models\Supplier\Host as SupplierHost;
final class Host extends Type implements ProductItem
{
use NextKey;
const RECORD_ID = '';
protected $table = 'product_host';
// 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_host_id');
}
/* INTERFACES */
public function getContractTermAttribute(): int
{
@@ -24,4 +43,24 @@ class Host extends ProductType
{
return FALSE;
}
public function allowance(): Collection
{
// TODO: Implement allowance() method.
}
public function allowance_string(): string
{
// TODO: Implement allowance_string() method.
}
public function getCostAttribute(): float
{
// TODO: Implement getCostAttribute() method.
}
public function getSupplierAttribute()
{
// TODO: Implement getSupplierAttribute() method.
}
}

View File

@@ -4,16 +4,30 @@ namespace App\Models\Product;
use Illuminate\Support\Collection;
use App\Interfaces\ProductSupplier;
use App\Models\Base\ProductType;
use App\Traits\NextKey;
use App\Interfaces\ProductItem;
use App\Models\Service\SSL as ServiceSSL;
use App\Models\Supplier\SSL as SupplierSSL;
class SSL extends ProductType implements ProductSupplier
final class SSL extends Type implements ProductItem
{
use NextKey;
const RECORD_ID = 'ssl';
protected $table = 'product_ssl';
protected $table = 'ab_ssl';
// 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_ssl_id');
}
/* INTERFACES */
public function allowance(): Collection
{

View File

@@ -0,0 +1,25 @@
<?php
namespace App\Models\Product;
use Illuminate\Database\Eloquent\Model;
use App\Models\Product;
use App\Traits\{OrderServiceOptions,SiteID};
abstract class Type extends Model
{
use SiteID,OrderServiceOptions;
/* RELATIONS */
/**
* The product that sells this type
*
* @return \Illuminate\Database\Eloquent\Relations\MorphOne
*/
public function product()
{
return $this->morphOne(Product::class, null,'model','model_id');
}
}

View File

@@ -2,16 +2,15 @@
namespace App\Models\Product;
use App\Models\Base\ProductType;
use App\Traits\NextKey;
use App\Traits\OrderServiceOptions;
use Illuminate\Support\Collection;
class Voip extends ProductType
use App\Interfaces\ProductItem;
use App\Models\Service\Voip as ServiceVoip;
use App\Models\Supplier\Voip as SupplierVoip;
final class Voip extends Type implements ProductItem
{
use NextKey;
const RECORD_ID = '';
use OrderServiceOptions;
protected $table = 'product_voip';
protected $order_attributes = [
'options.phonenumber'=>[
@@ -40,7 +39,22 @@ class Voip extends ProductType
],
];
protected $order_model = \App\Models\Service\Voip::class;
// The model that is referenced when this product is ordered
protected string $order_model = ServiceVoip::class;
/* RELATIONS */
/**
* The offering supplied with this product
*
* @return \Illuminate\Database\Eloquent\Relations\HasOne
*/
public function supplied()
{
return $this->hasOne(SupplierVoip::class,'id','supplier_voip_id');
}
/* INTERFACES */
public function getContractTermAttribute(): int
{
@@ -56,4 +70,24 @@ class Voip extends ProductType
{
return TRUE;
}
public function allowance(): Collection
{
// TODO: Implement allowance() method.
}
public function allowance_string(): string
{
// TODO: Implement allowance_string() method.
}
public function getCostAttribute(): float
{
// TODO: Implement getCostAttribute() method.
}
public function getSupplierAttribute()
{
// TODO: Implement getSupplierAttribute() method.
}
}