diff --git a/database/migrations/create_blax_shop_tables.php.stub b/database/migrations/create_blax_shop_tables.php.stub index 7d8d5f1..a28633b 100644 --- a/database/migrations/create_blax_shop_tables.php.stub +++ b/database/migrations/create_blax_shop_tables.php.stub @@ -15,8 +15,11 @@ return new class extends Migration if (!Schema::hasTable(config('shop.tables.products', 'products'))) { Schema::create(config('shop.tables.products', 'products'), function (Blueprint $table) { $table->uuid('id')->primary(); + $table->string('name'); $table->string('slug')->unique(); $table->string('sku')->nullable()->unique(); + $table->text('short_description')->nullable(); + $table->longText('description')->nullable(); $table->string('type')->default('simple'); // simple, variable, grouped, external $table->string('stripe_product_id')->nullable(); $table->decimal('price', 10, 2)->default(0); @@ -54,6 +57,15 @@ return new class extends Migration } else { // Add new fields to existing products table Schema::table(config('shop.tables.products', 'products'), function (Blueprint $table) { + if (!Schema::hasColumn(config('shop.tables.products', 'products'), 'name')) { + $table->string('name')->after('id'); + } + if (!Schema::hasColumn(config('shop.tables.products', 'products'), 'short_description')) { + $table->text('short_description')->nullable()->after('sku'); + } + if (!Schema::hasColumn(config('shop.tables.products', 'products'), 'description')) { + $table->longText('description')->nullable()->after('short_description'); + } if (!Schema::hasColumn(config('shop.tables.products', 'products'), 'low_stock_threshold')) { $table->integer('low_stock_threshold')->nullable()->after('stock_quantity'); } diff --git a/src/Models/Product.php b/src/Models/Product.php index cbfed49..0e5e3e3 100644 --- a/src/Models/Product.php +++ b/src/Models/Product.php @@ -19,7 +19,10 @@ class Product extends Model implements Purchasable use HasFactory, HasUuids, HasMetaTranslation; protected $fillable = [ + 'name', 'slug', + 'short_description', + 'description', 'type', 'stripe_product_id', 'price',