Updates to Product Model, product updates, enable pricing update, improved formating of product services

This commit is contained in:
2023-05-04 22:17:42 +10:00
parent 95bb55aad8
commit 0f91ce4940
21 changed files with 491 additions and 138 deletions

View File

@@ -6,6 +6,7 @@ use Illuminate\Support\Collection;
use Leenooks\Traits\ScopeActive;
use App\Interfaces\ProductItem;
use App\Models\Invoice;
use App\Models\Service\Broadband as ServiceBroadband;
use App\Models\Supplier\Broadband as SupplierBroadband;
@@ -34,6 +35,8 @@ final class Broadband extends Type implements ProductItem
// The model that is referenced when this product is ordered
protected string $order_model = ServiceBroadband::class;
// When comparing billing/pricing/charging, what metric to normalise to
const DefaultBill = Invoice::BILL_MONTHLY;
// The model that the supplier supplies
const SupplierModel = SupplierBroadband::class;

View File

@@ -5,6 +5,7 @@ namespace App\Models\Product;
use Illuminate\Support\Collection;
use App\Interfaces\ProductItem;
use App\Models\Invoice;
use App\Models\Service\Domain as ServiceDomain;
use App\Models\Supplier\Domain as SupplierDomain;
@@ -31,6 +32,8 @@ final class Domain extends Type implements ProductItem
// The model that is referenced when this product is ordered
protected string $order_model = ServiceDomain::class;
// When comparing billing/pricing/charging, what metric to normalise to
const DefaultBill = Invoice::BILL_YEARLY;
// The model that the supplier supplies
const SupplierModel = SupplierDomain::class;

View File

@@ -5,6 +5,7 @@ namespace App\Models\Product;
use Illuminate\Support\Collection;
use App\Interfaces\ProductItem;
use App\Models\Invoice;
use App\Models\Service\Email as ServiceEmail;
use App\Models\Supplier\Email as SupplierEmail;
@@ -15,6 +16,8 @@ final class Email extends Type implements ProductItem
// The model that is referenced when this product is ordered
protected string $order_model = ServiceEmail::class;
// When comparing billing/pricing/charging, what metric to normalise to
const DefaultBill = Invoice::BILL_YEARLY;
// The model that the supplier supplies
const SupplierModel = SupplierEmail::class;

View File

@@ -5,6 +5,7 @@ namespace App\Models\Product;
use Illuminate\Support\Collection;
use App\Interfaces\ProductItem;
use App\Models\Invoice;
use App\Models\Service\Generic as ServiceGeneric;
use App\Models\Supplier\Generic as SupplierGeneric;
@@ -15,6 +16,8 @@ final class Generic extends Type implements ProductItem
// The model that is referenced when this product is ordered
protected string $order_model = ServiceGeneric::class;
// When comparing billing/pricing/charging, what metric to normalise to
const DefaultBill = Invoice::BILL_MONTHLY;
// The model that the supplier supplies
const SupplierModel = SupplierGeneric::class;

View File

@@ -5,6 +5,7 @@ namespace App\Models\Product;
use Illuminate\Support\Collection;
use App\Interfaces\ProductItem;
use App\Models\Invoice;
use App\Models\Service\Host as ServiceHost;
use App\Models\Supplier\Host as SupplierHost;
@@ -15,6 +16,8 @@ final class Host extends Type implements ProductItem
// The model that is referenced when this product is ordered
protected string $order_model = ServiceHost::class;
// When comparing billing/pricing/charging, what metric to normalise to
const DefaultBill = Invoice::BILL_MONTHLY;
// The model that the supplier supplies
const SupplierModel = SupplierHost::class;

View File

@@ -5,6 +5,7 @@ namespace App\Models\Product;
use Illuminate\Support\Collection;
use App\Interfaces\ProductItem;
use App\Models\Invoice;
use App\Models\Service\Phone as ServicePhone;
use App\Models\Supplier\Phone as SupplierPhone;
@@ -42,6 +43,8 @@ final class Phone extends Type implements ProductItem
// The model that is referenced when this product is ordered
protected string $order_model = ServicePhone::class;
// When comparing billing/pricing/charging, what metric to normalise to
const DefaultBill = Invoice::BILL_MONTHLY;
// The model that the supplier supplies
const SupplierModel = SupplierPhone::class;

View File

@@ -5,6 +5,7 @@ namespace App\Models\Product;
use Illuminate\Support\Collection;
use App\Interfaces\ProductItem;
use App\Models\Invoice;
use App\Models\Service\SSL as ServiceSSL;
use App\Models\Supplier\SSL as SupplierSSL;
@@ -15,6 +16,8 @@ final class SSL extends Type implements ProductItem
// The model that is referenced when this product is ordered
protected string $order_model = ServiceSSL::class;
// When comparing billing/pricing/charging, what metric to normalise to
const DefaultBill = Invoice::BILL_MONTHLY;
// The model that the supplier supplies
const SupplierModel = SupplierSSL::class;

View File

@@ -22,7 +22,7 @@ abstract class Type extends Model
*
* @return \Illuminate\Database\Eloquent\Relations\MorphMany
*/
public function products()
final public function products()
{
return $this->morphMany(Product::class, null,'model','model_id');
}
@@ -32,7 +32,7 @@ abstract class Type extends Model
*
* @return \Illuminate\Database\Eloquent\Relations\HasOne
*/
public function supplied()
final public function supplied()
{
return $this->hasOne(static::SupplierModel,'id','supplier_item_id');
}
@@ -61,4 +61,11 @@ abstract class Type extends Model
abort(500,'use product->supplied->category_name');
return static::category_name;
}
/* METHODs */
final function normalizeBillingInterval(): int
{
return static::DefaultBill;
}
}