DnsSection.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace ModulesGarden\Servers\ProxmoxCloudVps\App\UI\VmClone\Sections;
  3. use ModulesGarden\ProxmoxAddon\App\Services\Cloud\ProductService;
  4. use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Interfaces\ClientArea;
  5. use ModulesGarden\Servers\ProxmoxCloudVps\Core\Models\Whmcs\Server;
  6. use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Forms\Fields\Text;
  7. use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Forms\Sections\BaseSection;
  8. use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\VmClone\Validators\SearchdomainValidator;
  9. use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\VmClone\Validators\NameserverValidator;
  10. class DnsSection extends BaseSection implements ClientArea
  11. {
  12. use ProductService;
  13. public function initContent()
  14. {
  15. $this->initIds('dnsSection');
  16. $this->initFields();
  17. }
  18. public function initFields()
  19. {
  20. if($this->configuration()->isPermissionSearchdomain()){
  21. $domain = new Text('searchdomain');
  22. $domain->addValidator(new SearchdomainValidator(false));
  23. $domain->setDescription('description');
  24. $this->addField($domain);
  25. }
  26. if($this->configuration()->isPermissionNameservers()){
  27. $server = Server::select('id', 'nameserver1ip', 'nameserver2ip')->findOrFail($this->getWhmcsParamByKey('serverid'));
  28. //ns1
  29. $ns1 = new Text('nameserver[0]');
  30. $ns1->addValidator(new NameserverValidator());
  31. $ns1->setDefaultValue(trim($server->nameserver1ip));
  32. $ns1->setDescription('description');
  33. $this->addField($ns1);
  34. //ns2
  35. $ns2 = new Text('nameserver[1]');
  36. $ns2->addValidator(new NameserverValidator());
  37. $ns2->setDefaultValue(trim($server->nameserver2ip));
  38. $ns2->setDescription('description');
  39. $this->addField($ns2);
  40. }
  41. }
  42. }