feat(server): add show_on_tv product flag and public /tv products API

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-18 17:17:01 +03:30
co-authored by Cursor
parent da9f98b958
commit e158831fd3
6 changed files with 177 additions and 0 deletions
+25
View File
@@ -19,6 +19,7 @@ class Product extends Model
private static ?bool $priceColumnExists = null;
private static ?bool $orderLimitColumnsExist = null;
private static ?bool $showInAssetsColumnExists = null;
private static ?bool $showOnTvColumnExists = null;
private static ?bool $useLastPriceIfZeroColumnExists = null;
private static ?bool $directPriceColumnExists = null;
private static ?bool $appPriceColumnExists = null;
@@ -46,6 +47,9 @@ class Product extends Model
if (!static::hasShowInAssetsColumn()) {
unset($product->attributes['show_in_assets']);
}
if (!static::hasShowOnTvColumn()) {
unset($product->attributes['show_on_tv']);
}
if (!static::hasUseLastPriceIfZeroColumn()) {
unset($product->attributes['use_last_price_if_zero']);
}
@@ -231,6 +235,24 @@ class Product extends Model
return static::$showInAssetsColumnExists;
}
public static function hasShowOnTvColumn(): bool
{
if (static::$showOnTvColumnExists !== null) {
return static::$showOnTvColumnExists;
}
try {
static::$showOnTvColumnExists = Schema::hasColumn(
(new static)->getTable(),
'show_on_tv'
);
} catch (\Throwable) {
static::$showOnTvColumnExists = false;
}
return static::$showOnTvColumnExists;
}
public static function hasUseLastPriceIfZeroColumn(): bool
{
if (static::$useLastPriceIfZeroColumnExists !== null) {
@@ -413,6 +435,7 @@ class Product extends Model
'for_barayand', // Whether it is for Barayand (boolean).
'show', // Whether to show the record (boolean).
'show_in_assets', // Show balance on customer assets page cards
'show_on_tv', // Show this product on customer /tv board
'trade_by_quantity', // UI معامله مقداری: ارزش کل + مقدار
'use_last_price_if_zero', // Keep last DB price when automatic provider returns zero
'open_sell', // Whether selling is open (boolean).
@@ -448,6 +471,7 @@ class Product extends Model
protected $attributes = [
'show_in_assets' => false,
'show_on_tv' => false,
'trade_by_quantity' => false,
'use_last_price_if_zero' => false,
'cash_fee_buy_is_percent' => false,
@@ -461,6 +485,7 @@ class Product extends Model
'active' => 'boolean', // Cast to boolean.
'show' => 'boolean', // Cast to boolean.
'show_in_assets' => 'boolean',
'show_on_tv' => 'boolean',
'trade_by_quantity' => 'boolean',
'use_last_price_if_zero' => 'boolean',
'override_trading_hours' => 'boolean',