feat(product): add show_in_list toggle and TV price formula

- New `show_in_list` column to control product visibility in customer list
- New `tv_price_formula_enabled` + `tv_price_formula` columns for separate TV pricing
- FormulaPriceService: isTvEnabled() and calculateTvForProduct()
- listTvProducts applies TV formula overrides before returning
- filterProductData handles both new field sets

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-19 11:51:54 +03:30
co-authored by Cursor
parent b0296c6e94
commit a321ebdaad
7 changed files with 348 additions and 0 deletions
@@ -0,0 +1,45 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
if (!Schema::hasTable('products')) {
return;
}
if (!Schema::hasColumn('products', 'show_in_list')) {
Schema::table('products', function (Blueprint $table) {
if (Schema::hasColumn('products', 'show_on_tv')) {
$table->boolean('show_in_list')->default(true)->after('show_on_tv');
} elseif (Schema::hasColumn('products', 'show_in_assets')) {
$table->boolean('show_in_list')->default(true)->after('show_in_assets');
} elseif (Schema::hasColumn('products', 'show')) {
$table->boolean('show_in_list')->default(true)->after('show');
} else {
$table->boolean('show_in_list')->default(true);
}
});
} else {
DB::statement(
'ALTER TABLE `products` MODIFY COLUMN `show_in_list` TINYINT(1) NOT NULL DEFAULT 1 COMMENT ''نمایش در لیست محصولات مشتری'''
);
}
}
public function down(): void
{
if (!Schema::hasTable('products') || !Schema::hasColumn('products', 'show_in_list')) {
return;
}
Schema::table('products', function (Blueprint $table) {
$table->dropColumn('show_in_list');
});
}
};
@@ -0,0 +1,40 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('products', function (Blueprint $table) {
if (! Schema::hasColumn('products', 'tv_price_formula_enabled')) {
if (Schema::hasColumn('products', 'price_formula')) {
$table->boolean('tv_price_formula_enabled')->default(false)->after('price_formula');
} else {
$table->boolean('tv_price_formula_enabled')->default(false);
}
}
if (! Schema::hasColumn('products', 'tv_price_formula')) {
$table->text('tv_price_formula')->nullable()->after('tv_price_formula_enabled');
}
});
}
public function down(): void
{
Schema::table('products', function (Blueprint $table) {
$drop = [];
if (Schema::hasColumn('products', 'tv_price_formula_enabled')) {
$drop[] = 'tv_price_formula_enabled';
}
if (Schema::hasColumn('products', 'tv_price_formula')) {
$drop[] = 'tv_price_formula';
}
if ($drop) {
$table->dropColumn($drop);
}
});
}
};