etehadie removed

This commit is contained in:
2026-06-04 14:19:54 +03:30
parent a643ba58b7
commit f9c5ca109d
13 changed files with 134 additions and 76 deletions
+25 -6
View File
@@ -2,6 +2,7 @@
namespace App\Services;
use App\Models\Cnt;
use App\Models\Setting;
class ConfigService
@@ -60,8 +61,7 @@ class ConfigService
* اولویت:
* 1) price_provider (یا price_primary_source قدیمی)
* 2) montzar_price=true → montzar (ابشده خانگی و پروژه‌های فعلی)
* 3) price_method پر و montzar خاموش → etehadie (گلد علی)
* 4) پیش‌فرض فایل: montzar
* 3) پیش‌فرض فایل: montzar
*/
public function priceProvider(): string
{
@@ -76,15 +76,29 @@ class ConfigService
return 'montzar';
}
if ($this->getString('price_method') !== '') {
return 'etehadie';
}
$default = strtolower((string) config('price_providers.price_provider', 'montzar'));
return in_array($default, self::PRICE_PROVIDERS, true) ? $default : 'montzar';
}
/**
* شناسه محصول آبشده پیش‌فرض: اول settings، بعد جدول const.
*/
public function mainProductId(): ?int
{
$fromSettings = $this->getString('main_product', '');
if ($fromSettings !== '' && is_numeric($fromSettings)) {
return (int) $fromSettings;
}
$fromConst = Cnt::where('key', 'main_product')->value('value');
if ($fromConst !== null && $fromConst !== '' && is_numeric($fromConst)) {
return (int) $fromConst;
}
return null;
}
/** @deprecated از priceProvider() استفاده کن */
public function pricePrimarySource(): string
{
@@ -103,6 +117,11 @@ class ConfigService
return $this->priceProvider() === 'etehadie';
}
public function usesMainProductPricing(): bool
{
return $this->priceProvider() === 'main_product';
}
public function UpdateConfig($name, $value)
{
return Setting::updateOrCreate(