feat: Refactor addon management to use AddonType and AddonInputType enums, update the database schema, and implement a grouped datatable display for addons.

This commit is contained in:
pbao9
2026-02-13 11:31:54 +07:00
parent b127fa7c66
commit 245f5ade37
11 changed files with 684 additions and 216 deletions
@@ -0,0 +1,22 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('product_addon', function (Blueprint $table) {
$table->renameColumn('type_id', 'type');
});
}
public function down(): void
{
Schema::table('product_addon', function (Blueprint $table) {
$table->renameColumn('type', 'type_id');
});
}
};
+109 -12
View File
@@ -10,42 +10,139 @@ class AddonSeeder extends Seeder
public function run(): void
{
$addons = [
// VPS Addons
[
'type_id' => 'vps',
'type' => 'vps',
'code' => 'cpu',
'name' => 'CPU',
'price' => 100000,
'min' => 0,
'max' => 30,
'price' => 20000,
'min' => 1,
'max' => 32,
'step' => 1,
'prefix' => 'vCore',
'input_type' => 'number',
'status' => true,
'sort_order' => 0,
],
[
'type_id' => 'vps',
'type' => 'vps',
'code' => 'ram',
'name' => 'RAM',
'price' => 50000,
'min' => 0,
'max' => 32,
'price' => 100000,
'min' => 1,
'max' => 64,
'step' => 1,
'prefix' => 'GB',
'input_type' => 'number',
'status' => true,
'sort_order' => 1,
],
[
'type_id' => 'vps',
'type' => 'vps',
'code' => 'disk',
'name' => 'SSD',
'price' => 4000,
'min' => 0,
'max' => 1500,
'step' => 10,
'min' => 25,
'max' => 2000,
'step' => 25,
'prefix' => 'GB',
'input_type' => 'number',
'status' => true,
'sort_order' => 2,
],
[
'type' => 'vps',
'code' => 'gpu',
'name' => 'GPU',
'price' => 500000,
'min' => 0,
'max' => 4,
'step' => 1,
'prefix' => 'GB',
'input_type' => 'select',
'status' => true,
'sort_order' => 3,
],
[
'type' => 'vps',
'code' => 'bandwidth',
'name' => 'Bandwidth',
'price' => 50000,
'min' => 100,
'max' => 10000,
'step' => 100,
'prefix' => 'Mbps',
'input_type' => 'slider',
'status' => true,
'sort_order' => 4,
],
// Hosting Addons
[
'type' => 'hosting',
'code' => 'hosting_cpu',
'name' => 'CPU',
'price' => 15000,
'min' => 1,
'max' => 8,
'step' => 1,
'prefix' => 'Core',
'input_type' => 'number',
'status' => true,
'sort_order' => 10,
],
[
'type' => 'hosting',
'code' => 'hosting_ram',
'name' => 'RAM',
'price' => 25000,
'min' => 512,
'max' => 16384,
'step' => 512,
'prefix' => 'MB',
'input_type' => 'number',
'status' => true,
'sort_order' => 11,
],
[
'type' => 'hosting',
'code' => 'hosting_disk',
'name' => 'Disk',
'price' => 2000,
'min' => 5,
'max' => 500,
'step' => 5,
'prefix' => 'GB',
'input_type' => 'number',
'status' => true,
'sort_order' => 12,
],
[
'type' => 'hosting',
'code' => 'hosting_bandwidth',
'name' => 'Bandwidth',
'price' => 10000,
'min' => 10,
'max' => 1000,
'step' => 10,
'prefix' => 'GB',
'input_type' => 'slider',
'status' => true,
'sort_order' => 13,
],
[
'type' => 'hosting',
'code' => 'hosting_ip',
'name' => 'IP Address',
'price' => 30000,
'min' => 0,
'max' => 5,
'step' => 1,
'prefix' => 'IP',
'input_type' => 'number',
'status' => true,
'sort_order' => 14,
],
];
Addon::upsert($addons, ['code']);
+4 -4
View File
@@ -17,7 +17,7 @@ class OsSeeder extends Seeder
[
'name' => 'Ubuntu',
'thumbnail' => 'ubuntu.png',
'module_host_id' => 1,
'module_host_id' => null,
'status' => 1,
'versions' => [
'20.04 LTS',
@@ -28,7 +28,7 @@ class OsSeeder extends Seeder
[
'name' => 'CentOS',
'thumbnail' => 'centos.png',
'module_host_id' => 1,
'module_host_id' => null,
'status' => 1,
'versions' => [
'7',
@@ -38,7 +38,7 @@ class OsSeeder extends Seeder
[
'name' => 'Debian',
'thumbnail' => 'debian.png',
'module_host_id' => 1,
'module_host_id' => null,
'status' => 1,
'versions' => [
'10',
@@ -49,7 +49,7 @@ class OsSeeder extends Seeder
[
'name' => 'Windows Server',
'thumbnail' => 'windows.png',
'module_host_id' => 1,
'module_host_id' => null,
'status' => 1,
'versions' => [
'2016',