feat: Enhance product support in Cart and OrderItem models
- Added new fields 'billing_cycle' and 'product_pricing_id' to Cart and OrderItem models. - Updated product retrieval logic to support both new and legacy systems. - Introduced relationships for Product and ProductPricings in Cart and OrderItem models. - Created migration to add new fields to the carts and order_item tables. - Updated frontend service index to handle new pricing structure and billing cycles. - Improved UI components for better user experience in product selection and pricing display. - Refactored action buttons in various views for consistency and improved styling.
This commit is contained in:
+60
@@ -0,0 +1,60 @@
|
||||
<?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
|
||||
{
|
||||
// Add support for new Product system to carts table
|
||||
Schema::table('carts', function (Blueprint $table) {
|
||||
if (!Schema::hasColumn('carts', 'billing_cycle')) {
|
||||
$table->string('billing_cycle', 50)->nullable()->after('months')->comment('Billing cycle: monthly, semi_annually, annually, etc.');
|
||||
}
|
||||
if (!Schema::hasColumn('carts', 'product_pricing_id')) {
|
||||
$table->unsignedBigInteger('product_pricing_id')->nullable()->after('billing_cycle')->comment('Link to product_pricings table');
|
||||
$table->index('product_pricing_id');
|
||||
}
|
||||
|
||||
// Make type_product nullable for new Product system
|
||||
$table->integer('type_product')->nullable()->change();
|
||||
});
|
||||
|
||||
// Add support for new Product system to order__order_item table
|
||||
Schema::table('order__order_item', function (Blueprint $table) {
|
||||
if (!Schema::hasColumn('order__order_item', 'billing_cycle')) {
|
||||
$table->string('billing_cycle', 50)->nullable()->after('months')->comment('Billing cycle: monthly, semi_annually, annually, etc.');
|
||||
}
|
||||
if (!Schema::hasColumn('order__order_item', 'product_pricing_id')) {
|
||||
$table->unsignedBigInteger('product_pricing_id')->nullable()->after('billing_cycle')->comment('Link to product_pricings table');
|
||||
$table->index('product_pricing_id');
|
||||
}
|
||||
|
||||
// Make product_type nullable for new Product system
|
||||
if (Schema::hasColumn('order__order_item', 'product_type')) {
|
||||
$table->integer('product_type')->nullable()->change();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('carts', function (Blueprint $table) {
|
||||
$table->dropColumn(['billing_cycle', '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']);
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user