mirror of
https://github.com/getnamingo/registry.git
synced 2025-05-14 00:27:03 +02:00
Added TLD create
This commit is contained in:
parent
2d6111ccec
commit
5fc5ffb218
5 changed files with 98 additions and 17 deletions
|
@ -224,6 +224,10 @@
|
|||
"audit": true,
|
||||
"skip": null
|
||||
},
|
||||
"premium_domain_categories": {
|
||||
"audit": true,
|
||||
"skip": null
|
||||
},
|
||||
"premium_domain_pricing": {
|
||||
"audit": true,
|
||||
"skip": null
|
||||
|
|
|
@ -264,7 +264,70 @@ class SystemController extends Controller
|
|||
]
|
||||
);
|
||||
|
||||
//todo: add premium domains and price categories
|
||||
for ($i = 1; $i <= 10; $i++) {
|
||||
$categoryNameKey = 'categoryName' . $i;
|
||||
$categoryPriceKey = 'categoryPrice' . $i;
|
||||
|
||||
if (isset($data[$categoryNameKey]) && isset($data[$categoryPriceKey]) && $data[$categoryNameKey] !== '' && $data[$categoryPriceKey] !== '') {
|
||||
$db->exec(
|
||||
'INSERT INTO premium_domain_categories (category_name, category_price) VALUES (?, ?) ON DUPLICATE KEY UPDATE category_price = VALUES(category_price)',
|
||||
[
|
||||
$data[$categoryNameKey],
|
||||
$data[$categoryPriceKey]
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$uploadedFiles = $request->getUploadedFiles();
|
||||
|
||||
if (!empty($uploadedFiles['premiumNamesFile'])) {
|
||||
$file = $uploadedFiles['premiumNamesFile'];
|
||||
|
||||
// Check if the upload was successful
|
||||
if ($file->getError() !== UPLOAD_ERR_OK) {
|
||||
$this->container->get('flash')->addMessage('error', 'Upload failed with error code ' . $file->getError());
|
||||
return $response->withHeader('Location', '/registry/tld/create')->withStatus(302);
|
||||
}
|
||||
|
||||
// Validate file type and size
|
||||
if ($file->getClientMediaType() !== 'text/csv' || $file->getSize() > 5 * 1024 * 1024) {
|
||||
$this->container->get('flash')->addMessage('error', 'Invalid file type or size');
|
||||
return $response->withHeader('Location', '/registry/tld/create')->withStatus(302);
|
||||
}
|
||||
|
||||
// Process the CSV file
|
||||
$stream = $file->getStream();
|
||||
$csvContent = $stream->getContents();
|
||||
|
||||
$lines = explode(PHP_EOL, $csvContent);
|
||||
foreach ($lines as $line) {
|
||||
$data = str_getcsv($line);
|
||||
if (count($data) >= 2) {
|
||||
$domainName = $data[0];
|
||||
$categoryName = $data[1];
|
||||
|
||||
// Find the category ID
|
||||
$categoryResult = $this->db->select("SELECT id FROM premium_domain_categories WHERE category_name = :categoryName", ['categoryName' => $categoryName]);
|
||||
|
||||
if ($categoryResult) {
|
||||
$categoryId = $categoryResult[0]['id'];
|
||||
|
||||
// Insert into premium_domain_pricing
|
||||
$db->exec(
|
||||
'INSERT INTO premium_domain_pricing (domain_name, category_id) VALUES (?, ?) ON DUPLICATE KEY UPDATE category_id = VALUES(category_id)',
|
||||
[
|
||||
$domainName,
|
||||
$categoryId
|
||||
]
|
||||
);
|
||||
} else {
|
||||
$this->container->get('flash')->addMessage('error', 'Premium names category ' . $categoryName . ' not found');
|
||||
return $response->withHeader('Location', '/registry/tld/create')->withStatus(302);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$db->commit();
|
||||
} catch (Exception $e) {
|
||||
|
|
|
@ -91,7 +91,7 @@
|
|||
<tbody>
|
||||
<tr>
|
||||
<td>Create</td>
|
||||
<td><input type="number" class="form-control" name="createm0" placeholder="0.00" required min="0"></td>
|
||||
<td><input type="number" class="form-control" name="createm0" placeholder="0.00" required min="0" value="0.00"></td>
|
||||
<td><input type="number" class="form-control" name="createm12" placeholder="0.00" required min="0"></td>
|
||||
<td><input type="number" class="form-control" name="createm24" placeholder="0.00" required min="0"></td>
|
||||
<td><input type="number" class="form-control" name="createm36" placeholder="0.00" required min="0"></td>
|
||||
|
@ -105,7 +105,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td>Renew</td>
|
||||
<td><input type="number" class="form-control" name="renewm0" placeholder="0.00" required min="0"></td>
|
||||
<td><input type="number" class="form-control" name="renewm0" placeholder="0.00" required min="0" value="0.00"></td>
|
||||
<td><input type="number" class="form-control" name="renewm12" placeholder="0.00" required min="0"></td>
|
||||
<td><input type="number" class="form-control" name="renewm24" placeholder="0.00" required min="0"></td>
|
||||
<td><input type="number" class="form-control" name="renewm36" placeholder="0.00" required min="0"></td>
|
||||
|
@ -119,7 +119,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td>Transfer</td>
|
||||
<td><input type="number" class="form-control" name="transferm0" placeholder="0.00" required min="0"></td>
|
||||
<td><input type="number" class="form-control" name="transferm0" placeholder="0.00" required min="0" value="0.00"></td>
|
||||
<td><input type="number" class="form-control" name="transferm12" placeholder="0.00" required min="0"></td>
|
||||
<td><input type="number" class="form-control" name="transferm24" placeholder="0.00" required min="0"></td>
|
||||
<td><input type="number" class="form-control" name="transferm36" placeholder="0.00" required min="0"></td>
|
||||
|
|
|
@ -603,15 +603,24 @@ CREATE TABLE IF NOT EXISTS `registry`.`promotion_pricing` (
|
|||
FOREIGN KEY (`tld_id`) REFERENCES `domain_tld`(`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Promotions';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `registry`.`premium_domain_categories` (
|
||||
`category_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`category_name` varchar(255) NOT NULL,
|
||||
`category_price` decimal(10,2) NOT NULL,
|
||||
PRIMARY KEY (`category_id`),
|
||||
UNIQUE KEY `category_name` (`category_name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Premium Domains Categories';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `registry`.`premium_domain_pricing` (
|
||||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
`domain_name` VARCHAR(255) NOT NULL,
|
||||
`tld_id` INT UNSIGNED NOT NULL,
|
||||
`start_date` DATE NOT NULL,
|
||||
`end_date` DATE,
|
||||
`price` DECIMAL(10,2) NOT NULL,
|
||||
`conditions` TEXT,
|
||||
FOREIGN KEY (`tld_id`) REFERENCES `domain_tld`(`id`)
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`domain_name` varchar(255) NOT NULL,
|
||||
`tld_id` int(10) unsigned NOT NULL,
|
||||
`category_id` int(10) unsigned DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `tld_id` (`tld_id`),
|
||||
KEY `category_id` (`category_id`),
|
||||
CONSTRAINT `premium_domain_pricing_ibfk_1` FOREIGN KEY (`tld_id`) REFERENCES `domain_tld` (`id`),
|
||||
CONSTRAINT `premium_domain_pricing_ibfk_2` FOREIGN KEY (`category_id`) REFERENCES `premium_domain_categories` (`category_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Premium Domains';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `registry`.`ticket_categories` (
|
||||
|
|
|
@ -581,15 +581,20 @@ CREATE TABLE registry.promotion_pricing (
|
|||
FOREIGN KEY ("tld_id") REFERENCES registry.domain_tld("id")
|
||||
);
|
||||
|
||||
CREATE TABLE registry.premium_domain_categories (
|
||||
"category_id" serial8 PRIMARY KEY,
|
||||
"category_name" VARCHAR(255) NOT NULL,
|
||||
"category_price" NUMERIC(10, 2) NOT NULL,
|
||||
UNIQUE (category_name)
|
||||
);
|
||||
|
||||
CREATE TABLE registry.premium_domain_pricing (
|
||||
"id" serial8 PRIMARY KEY,
|
||||
"domain_name" VARCHAR(255) NOT NULL,
|
||||
"tld_id" INT CHECK ("tld_id" >= 0) NOT NULL,
|
||||
"start_date" DATE NOT NULL,
|
||||
"end_date" DATE,
|
||||
"price" DECIMAL(10,2) NOT NULL,
|
||||
"conditions" TEXT,
|
||||
FOREIGN KEY ("tld_id") REFERENCES registry.domain_tld("id")
|
||||
"category_id" INT,
|
||||
FOREIGN KEY ("tld_id") REFERENCES registry.domain_tld("id"),
|
||||
FOREIGN KEY ("category_id") REFERENCES registry.premium_domain_categories("category_id")
|
||||
);
|
||||
|
||||
-- Create custom types for status and priority
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue