Enable creation of domains and domain service editing

This commit is contained in:
Deon George
2022-10-18 14:17:50 +11:00
parent 0b4e3a9341
commit c96d264c8f
12 changed files with 143 additions and 25 deletions

View File

@@ -108,6 +108,7 @@ class OrderController extends Controller
$so->ordered_by = Auth::id();
$so->active = FALSE;
$so->model = $order ? get_class($order) : NULL;
$so->recur_schedule = $po->price_recur_default;
if ($order && $order->order_info) {
$so->order_info = $order->order_info;

View File

@@ -28,6 +28,14 @@ class ProductController extends Controller
->sortBy('name')
->values();
case 'App\Models\Product\Domain':
return Product\Domain::select(['id','supplier_item_id'])
->with(['supplied.supplier_detail.supplier'])
->get()
->map(function($item) { return ['id'=>$item->id,'name'=>sprintf('%s: %s',$item->supplied->supplier_detail->supplier->name,$item->supplied->name)]; })
->sortBy('name')
->values();
case 'App\Models\Product\Email':
return Product\Email::select(['id','supplier_item_id'])
->with(['supplied.supplier_detail.supplier'])

View File

@@ -415,10 +415,12 @@ class ServiceController extends Controller
$o->type->save();
// @todo create a validator for service
if ($request->post('invoice_next_at'))
$o->invoice_next_at = $request->invoice_next_at;
if ($request->post('recur_schedule'))
$o->recur_schedule = $request->recur_schedule;
// Also update our service start_at date.
// @todo We may want to make start_at/stop_at dynamic values calculated by the type records
if ($request->post('start_at'))

View File

@@ -32,7 +32,7 @@ class ProductAddEdit extends FormRequest
'active' => 'sometimes|accepted',
'model' => 'sometimes|string', // @todo Check that it is a valid model type
'model_id' => 'sometimes|int', // @todo Check that it is a valid model type
'accounting' => 'sometimes|string',
'accounting' => 'nullable|string',
];
}
}

View File

@@ -12,6 +12,22 @@ final class Domain extends Type implements ProductItem
{
protected $table = 'product_domain';
// Information required during the order process
protected array $order_attributes = [
'options.domain'=>[
'request'=>'options.domain',
'key'=>'domain_name',
'validation'=>'required|min:3',
'validation_message'=>'Domain Name is a required field.',
],
'options.tld_id'=>[
'request'=>'options.tld_id',
'key'=>'tld_id',
'validation'=>'required|exists:tlds,id',
'validation_message'=>'Domain TLD is a required field.',
],
];
// The model that is referenced when this product is ordered
protected string $order_model = ServiceDomain::class;

View File

@@ -800,7 +800,7 @@ class Service extends Model implements IDs
*/
public function getNameDetailAttribute()
{
return ($this->type && $this->type->getServiceDescriptionAttribute()) ? $this->type->getServiceDescriptionAttribute() : 'No Description';
return ($this->type && ($this->type->getServiceDescriptionAttribute() !== NULL)) ? $this->type->getServiceDescriptionAttribute() : 'No Description';
}
/**

View File

@@ -28,11 +28,14 @@ class Domain extends Type
return [
'domain_name' => 'nullable|string|min:2',
'tld_id' => 'required|exists:tlds,id',
'expire_at' => 'required|date',
'domain_registrar_id' => 'required|exists:domain_registrars,id',
'registrar_account' => 'nullable|string',
'registrar_ns' => 'nullable|string',
'registrar_username' => 'nullable|string',
'connect_at' => 'nullable|date',
'start_at' => 'nullable|date',
'expire_at' => 'nullable|date|after:start_at',
'recur_schedule' => 'nullable|int', // @todo insure value is at least 1 yr and not higher than Invoice::billing_periods
];
}