diff --git a/database/migrations/create_blax_shop_tables.php.stub b/database/migrations/create_blax_shop_tables.php.stub index 0728db5..6274c3d 100644 --- a/database/migrations/create_blax_shop_tables.php.stub +++ b/database/migrations/create_blax_shop_tables.php.stub @@ -117,13 +117,24 @@ return new class extends Migration Schema::create(config('shop.tables.product_prices', 'product_prices'), function (Blueprint $table) { $table->uuid('id')->primary(); $table->uuid('product_id'); - $table->string('currency', 3)->default('USD'); - $table->decimal('price', 10, 2); $table->string('stripe_price_id')->nullable(); + $table->string('name')->nullable(); + $table->string('type')->default('one_time'); // one_time, recurring + $table->string('currency', 3)->default('USD'); + $table->integer('price')->default(0); // Store as smallest currency unit (cents) + $table->integer('sale_price')->nullable(); $table->boolean('is_default')->default(false); + $table->boolean('active')->default(true); + $table->string('billing_scheme')->nullable(); // per_unit, tiered + $table->string('interval')->nullable(); // day, week, month, year + $table->integer('interval_count')->nullable(); + $table->integer('trial_period_days')->nullable(); + $table->json('meta')->nullable(); $table->timestamps(); $table->index(['product_id', 'currency']); + $table->index(['product_id', 'is_default']); + $table->index(['active', 'type']); $table->foreign('product_id')->references('id')->on(config('shop.tables.products', 'products'))->onDelete('cascade'); }); } diff --git a/src/Console/Commands/ShopAddExampleProducts.php b/src/Console/Commands/ShopAddExampleProducts.php index 3eeef35..e1439d8 100644 --- a/src/Console/Commands/ShopAddExampleProducts.php +++ b/src/Console/Commands/ShopAddExampleProducts.php @@ -268,7 +268,7 @@ class ShopAddExampleProducts extends Command foreach ($attributes as $index => $attr) { ProductAttribute::create([ 'product_id' => $product->id, - 'name' => $attr['name'], + 'key' => $attr['name'], 'value' => $attr['value'], 'sort_order' => $index, 'meta' => json_encode((object)[]), diff --git a/src/Models/ProductAttribute.php b/src/Models/ProductAttribute.php index 1a33a41..8127b42 100644 --- a/src/Models/ProductAttribute.php +++ b/src/Models/ProductAttribute.php @@ -13,7 +13,7 @@ class ProductAttribute extends Model protected $fillable = [ 'product_id', - 'name', + 'key', 'value', 'sort_order', 'meta',