This commit is contained in:
pbao9
2026-02-06 16:18:15 +07:00
parent 92151261b3
commit d7aadf7544
35 changed files with 1606 additions and 1439 deletions
@@ -14,21 +14,14 @@ 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();
$table->string('short_description')->nullable();
$table->text('description')->nullable();
// Pricing
$table->decimal('price', 12, 2)->nullable();
$table->decimal('price_sale', 12, 2)->nullable();
$table->decimal('setup_fee', 12, 2)->default(0);
$table->string('currency', 10)->default('USD');
$table->string('billing_cycle')->default('monthly');
// Trial / stock
$table->unsignedInteger('trial_days')->default(0);
$table->integer('stock')->nullable();
$table->boolean('is_unlimited')->default(true);
@@ -38,21 +31,28 @@ return new class extends Migration {
$table->string('gpu')->nullable();
$table->string('disk')->nullable();
$table->string('bandwidth')->nullable();
// Extra
$table->json('features')->nullable();
$table->json('metadata')->nullable();
$table->decimal('setup_fee', 15, 2)->default(0);
$table->integer('trial_days')->default(0);
$table->boolean('is_active')->default(true);
$table->integer('sort_order')->default(0);
$table->timestamp('published_at')->nullable();
$table->foreign('product_categories_id')
->references('id')
->on('product_categories')
->onDelete('cascade');
$table->foreign('product_categories_id')->references('id')->on('product_categories')->onDelete('cascade');
$table->softDeletes();
$table->timestamps();
});
}
public function down(): void
@@ -0,0 +1,56 @@
<?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_pricings', function (Blueprint $table) {
$table->id();
// FK
$table->foreignId('product_id')
->constrained('products')
->cascadeOnDelete();
// billing cycle type
$table->string('billing_cycle', 50);
/*
one_time
monthly
quarterly
semi_annually
annually
biennially (2 years)
triennially (3 years)
*/
// pricing
$table->decimal('price', 15, 2);
$table->decimal('price_sale', 15, 2)->nullable();
$table->string('currency', 10)->default('USD');
$table->boolean('is_active')->default(true);
$table->timestamps();
// tránh trùng 1 chu kỳ trên 1 product
$table->unique(['product_id', 'billing_cycle']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('product_pricings');
}
};