<?php

namespace App\Models\Product;

use Illuminate\Support\Collection;

use App\Models\Invoice;
use App\Models\Service\Phone as ServicePhone;
use App\Models\Supplier\Phone as SupplierPhone;

final class Phone extends Type
{
	protected $table = 'product_phone';

	protected array $order_attributes = [
		'options.phonenumber'=>[
			'request'=>'options.phonenumber',
			'key'=>'service_number',
			'validation'=>'nullable|size:10|unique:service_phone,service_number',
			'validation_message'=>'Phone Number is a required field.',
		],
		'options.supplier'=>[
			'request'=>'options.supplier',
			'key'=>'order_info.supplier',
			'validation'=>'required_with:options.phonenumber',
			'validation_message'=>'Phone Supplier is a required field.',
		],
		'options.supplieraccnum'=>[
			'request'=>'options.supplieraccnum',
			'key'=>'order_info.supplieraccnum',
			'validation'=>'required_with:options.phonenumber',
			'validation_message'=>'Phone Supplier Account Number is a required field.',
		],
		'options.notes'=>[
			'request'=>'options.notes',
			'key'=>'order_info.notes',
			'validation'=>'required_if:options.phonenumber,null',
			'validation_message'=>'Special Instructions here.',
		],
	];

	// 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;

	/* INTERFACES */

	public function allowance(): Collection
	{
		// TODO: Implement allowance() method.
	}

	public function allowance_string(): string
	{
		return "(TBA)";
	}

	public function hasUsage(): bool
	{
		return FALSE;
	}
}