feat: Implement comprehensive product management, including categories, pricing, and integration into the order system.
This commit is contained in:
@@ -14,14 +14,19 @@ return new class extends Migration {
|
||||
{
|
||||
Schema::create('order__order_item', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->bigInteger('order_id')->default(0)->index();
|
||||
$table->unsignedBigInteger('order_id')->index();
|
||||
$table->unsignedBigInteger('product_id')->nullable()->index();
|
||||
$table->string('billing_cycle', 50)->nullable();
|
||||
$table->integer('months')->default(0);
|
||||
$table->unsignedBigInteger('os_id')->nullable()->index();
|
||||
$table->string('server_name')->nullable();
|
||||
$table->integer('quantity')->default(1);
|
||||
$table->integer('price')->default(0);
|
||||
$table->tinyInteger('product_type');
|
||||
$table->timestamps();
|
||||
|
||||
// Foreign Keys
|
||||
$table->foreign('order_id')->references('id')->on('order')->onDelete('cascade');
|
||||
$table->foreign('product_id')->references('id')->on('products')->onDelete('set null');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ return new class extends Migration {
|
||||
$table->integer('quantity')->default(1);
|
||||
$table->tinyInteger('invoice_type')->default(1);
|
||||
$table->integer('price')->default(0);
|
||||
$table->tinyInteger('product_type');
|
||||
$table->string('product_type', 50)->nullable();
|
||||
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
@@ -12,11 +12,15 @@ return new class extends Migration {
|
||||
{
|
||||
Schema::create('order__order_addons', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('order_item_id')->index(); // FK đến order_items
|
||||
$table->unsignedBigInteger('addon_id');
|
||||
$table->unsignedBigInteger('order_item_id')->index();
|
||||
$table->unsignedBigInteger('addon_id')->index();
|
||||
$table->unsignedInteger('qty')->default(1);
|
||||
$table->unsignedInteger('price'); // đơn giá tại thời điểm mua
|
||||
$table->unsignedInteger('price');
|
||||
$table->timestamps();
|
||||
|
||||
// Foreign Keys
|
||||
$table->foreign('order_item_id')->references('id')->on('order__order_item')->onDelete('cascade');
|
||||
$table->foreign('addon_id')->references('id')->on('product_addon')->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -25,6 +29,6 @@ return new class extends Migration {
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('order_addons');
|
||||
Schema::dropIfExists('order__order_addons');
|
||||
}
|
||||
};
|
||||
|
||||
+3
-3
@@ -37,7 +37,7 @@ return new class extends Migration
|
||||
|
||||
// Make product_type nullable for new Product system
|
||||
if (Schema::hasColumn('order__order_item', 'product_type')) {
|
||||
$table->integer('product_type')->nullable()->change();
|
||||
$table->string('product_type', 50)->nullable()->change();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -49,12 +49,12 @@ return new class extends Migration
|
||||
{
|
||||
Schema::table('carts', function (Blueprint $table) {
|
||||
$table->dropColumn(['billing_cycle', 'product_pricing_id']);
|
||||
$table->dropIndex(['product_pricing_id']);
|
||||
// $table->dropIndex(['product_pricing_id']);
|
||||
});
|
||||
|
||||
Schema::table('order__order_item', function (Blueprint $table) {
|
||||
$table->dropColumn(['billing_cycle', 'product_pricing_id']);
|
||||
$table->dropIndex(['product_pricing_id']);
|
||||
// $table->dropIndex(['product_pricing_id']);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -15,8 +15,6 @@ class DatabaseSeeder extends Seeder
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
User::factory(1)->create();
|
||||
|
||||
$this->call(DomainTypeSeeder::class);
|
||||
$this->call(GroupSeeder::class);
|
||||
$this->call(Payment::class);
|
||||
|
||||
Reference in New Issue
Block a user