feat: Implement product and product category management with dedicated CRUD operations, services, and repositories.
This commit is contained in:
@@ -14,11 +14,11 @@ return new class extends Migration
|
||||
public function up()
|
||||
{
|
||||
Schema::create('module_host',function (Blueprint $table) {
|
||||
$table->id()->autoIncrement();
|
||||
$table->id();
|
||||
$table->string('name',100)->nullable();
|
||||
$table->string('host_id',255)->nullable();
|
||||
$table->string('template',255)->nullable();
|
||||
$table->foreignId('module_datacenter_id')->constrained('module_datacenter')->cascadeOnDelete()->nullable()->index();
|
||||
$table->foreignId('module_datacenter_id')->nullable()->constrained('module_datacenter', 'id', 'fk_mod_host_mod_dc');
|
||||
$table->string('console',255)->nullable();
|
||||
$table->string('iso_path',255)->nullable();
|
||||
$table->timestamps();
|
||||
@@ -32,6 +32,6 @@ return new class extends Migration
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('module_hosts');
|
||||
Schema::dropIfExists('module_host');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -13,12 +13,12 @@ return new class extends Migration {
|
||||
public function up()
|
||||
{
|
||||
Schema::create('module_datastore', function (Blueprint $table) {
|
||||
$table->id()->autoIncrement();
|
||||
$table->id();
|
||||
$table->string('name', 255)->nullable();
|
||||
$table->string('datastore', 255)->nullable();
|
||||
$table->string('type', 100)->nullable();
|
||||
$table->integer('space')->nullable();
|
||||
$table->foreignId('module_host_id')->index()->constrained('module_hosts')->cascadeOnDelete();
|
||||
$table->foreignId('module_host_id')->index()->constrained('module_host')->nullable();
|
||||
$table->tinyInteger('status')->default(1);
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
@@ -4,8 +4,7 @@ use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
return new class extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
@@ -13,12 +12,19 @@ return new class extends Migration
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('module_network',function (Blueprint $table) {
|
||||
$table->id()->autoIncrement();
|
||||
$table->string('name',255)->nullable();
|
||||
$table->string('type',100)->nullable();
|
||||
$table->string('network',100)->nullable();
|
||||
$table->foreignId('module_host_id')->constrained('module_host')->index()->cascadeOnDelete();
|
||||
Schema::create('module_network', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name', 255)->nullable();
|
||||
$table->string('type', 100)->nullable();
|
||||
$table->string('network', 100)->nullable();
|
||||
|
||||
$table->unsignedBigInteger('module_host_id')->nullable();
|
||||
|
||||
$table->foreign('module_host_id', 'fk_module_network_host')
|
||||
->references('id')
|
||||
->on('module_host')
|
||||
->nullOnDelete();
|
||||
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -16,13 +16,17 @@ return new class extends Migration
|
||||
Schema::create('module_ip_address',function (Blueprint $table) {
|
||||
$table->id()->autoIncrement();
|
||||
$table->string('vm_name',255)->nullable();
|
||||
$table->foreignId('module_network_id')->nullable()->constrained('module_network')->onDelete('set null')->index();
|
||||
$table->unsignedBigInteger('module_network_id')->nullable();
|
||||
$table->string('ip',100)->nullable();
|
||||
$table->string('gateway',100)->nullable();
|
||||
$table->string('netmask',100)->nullable();
|
||||
$table->string('dns',100)->nullable();
|
||||
$table->tinyInteger('status')->default(0)->comment('1: assign;0: free');
|
||||
$table->timestamps();
|
||||
$table->foreign('module_network_id', 'fk_module_ip_network')
|
||||
->references('id')
|
||||
->on('module_network')
|
||||
->nullOnDelete();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -17,9 +17,13 @@ return new class extends Migration
|
||||
$table->id()->autoIncrement();
|
||||
$table->string('name')->nullable();
|
||||
$table->string('thumbnail')->nullable();
|
||||
$table->foreignId('module_host_id')->constrained('module_host')->index()->nullable();
|
||||
$table->unsignedBigInteger('module_host_id')->nullable();
|
||||
$table->tinyInteger('status')->default(1);
|
||||
$table->timestamps();
|
||||
$table->foreign('module_host_id', 'fk_os_group_host')
|
||||
->references('id')
|
||||
->on('module_host')
|
||||
->nullOnDelete();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -15,10 +15,11 @@ return new class extends Migration {
|
||||
Schema::create('os', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('version', 100)->nullable();
|
||||
$table->foreignId('os_group_id')->constrained('os_group')->index();
|
||||
$table->unsignedBigInteger('os_group_id')->nullable();
|
||||
$table->string('template_id')->nullable();
|
||||
$table->tinyInteger('status')->default(1);
|
||||
$table->timestamps();
|
||||
$table->foreign('os_group_id', 'fk_os_group_id')->references('id')->on('os_group')->nullOnDelete();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('product_categories', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('slug')->unique();
|
||||
$table->foreignId('parent_id')->nullable()
|
||||
->constrained('product_categories')
|
||||
->nullOnDelete();
|
||||
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->integer('sort_order')->default(0);
|
||||
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('product_categories');
|
||||
}
|
||||
};
|
||||
@@ -13,7 +13,7 @@ return new class extends Migration {
|
||||
|
||||
// Product type
|
||||
$table->string('product_type', 50)->index();
|
||||
|
||||
$table->unsignedBigInteger('product_categories_id')->index();
|
||||
// Basic info
|
||||
$table->string('name');
|
||||
$table->string('slug')->unique();
|
||||
@@ -47,6 +47,9 @@ return new class extends Migration {
|
||||
$table->integer('sort_order')->default(0);
|
||||
$table->timestamp('published_at')->nullable();
|
||||
|
||||
|
||||
$table->foreign('product_categories_id')->references('id')->on('product_categories')->onDelete('cascade');
|
||||
$table->softDeletes();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
// Schema::create('product_vm_templates', function (Blueprint $table) {
|
||||
// $table->foreignId('product_id')->constrained('products')->cascadeOnDelete();
|
||||
// $table->foreignId('vm_template_id')->constrained('vm_templates')->cascadeOnDelete();
|
||||
// });
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('product_vm_templates');
|
||||
}
|
||||
};
|
||||
@@ -1,32 +0,0 @@
|
||||
<?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('module_datastore', function (Blueprint $table) {
|
||||
$table->unsignedBigInteger('module_host_id')->default(0)->change();
|
||||
});
|
||||
|
||||
Schema::table('module_datastore', function (Blueprint $table) {
|
||||
$table->foreign('module_host_id')
|
||||
->references('id')
|
||||
->on('module_host')
|
||||
->cascadeOnDelete();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('module_datastore', function (Blueprint $table) {
|
||||
$table->dropForeign(['module_host_id']);
|
||||
});
|
||||
|
||||
Schema::table('module_datastore', function (Blueprint $table) {
|
||||
$table->bigInteger('module_host_id')->default(0)->change();
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user