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:
@@ -244,6 +244,43 @@ class ProductController extends SuperController
|
||||
return response()->json($products);
|
||||
}
|
||||
|
||||
/**
|
||||
* تابلو /tv — بدون لاگین؛ فقط محصولات تیکخورده.
|
||||
*/
|
||||
public function listTvProducts()
|
||||
{
|
||||
if (! Product::hasShowOnTvColumn()) {
|
||||
return response()->json([]);
|
||||
}
|
||||
|
||||
$products = Product::with(['file'])
|
||||
->where('active', 1)
|
||||
->where('show_on_tv', true)
|
||||
->get();
|
||||
|
||||
if (app(ConfigService::class)->isStore()) {
|
||||
$categoryService = app(CategoryService::class);
|
||||
$products = $categoryService->filterProductsByVisibleCategories($products);
|
||||
$products = $categoryService->sortProductsForStore($products);
|
||||
}
|
||||
|
||||
$this->applyCustomerShow($products);
|
||||
|
||||
$products = $products->filter(function (Product $product) {
|
||||
return (bool) $product->show_on_tv;
|
||||
});
|
||||
|
||||
if (Product::hasPriceOffsetColumn()) {
|
||||
$products->each(function (Product $product) {
|
||||
if ($product->reading_method) {
|
||||
$product->makeHidden(['price_offset_percent']);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return response()->json($products->values()->all());
|
||||
}
|
||||
|
||||
public function ProductById($id)
|
||||
{
|
||||
if (! $this->isCustomerApiRequest()) {
|
||||
@@ -652,6 +689,12 @@ class ProductController extends SuperController
|
||||
$data['show_in_assets'] = !empty($data['show_in_assets']);
|
||||
}
|
||||
|
||||
if (!Product::hasShowOnTvColumn()) {
|
||||
unset($data['show_on_tv']);
|
||||
} elseif (array_key_exists('show_on_tv', $data)) {
|
||||
$data['show_on_tv'] = !empty($data['show_on_tv']);
|
||||
}
|
||||
|
||||
if (!Product::hasUseLastPriceIfZeroColumn()) {
|
||||
unset($data['use_last_price_if_zero']);
|
||||
} elseif (array_key_exists('use_last_price_if_zero', $data)) {
|
||||
|
||||
Reference in New Issue
Block a user