fix(settings): read SuperAdmin overlay via ConfigService everywhere
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@@ -21,8 +20,9 @@ class ChatWebhookService
|
||||
public function ensureRegisteredDetailed(int $maxAttempts = 3): array
|
||||
{
|
||||
$webhookUrl = $this->webhookUrl();
|
||||
$chatApi = Controller::Config('chat_api');
|
||||
$chatApiKey = Controller::Config('chat_api_key');
|
||||
$config = app(ConfigService::class);
|
||||
$chatApi = $config->getString('chat_api');
|
||||
$chatApiKey = $config->getString('chat_api_key');
|
||||
|
||||
if (! $chatApi || ! $chatApiKey) {
|
||||
return [
|
||||
@@ -128,7 +128,7 @@ class ChatWebhookService
|
||||
*/
|
||||
public function webhookUrl(): string
|
||||
{
|
||||
$base = trim((string) Controller::Config('chat_webhook_base_url'));
|
||||
$base = trim(app(ConfigService::class)->getString('chat_webhook_base_url'));
|
||||
if ($base === '' || $base === '0' || strtolower($base) === 'false') {
|
||||
$base = rtrim((string) config('app.url'), '/');
|
||||
} else {
|
||||
@@ -154,7 +154,7 @@ class ChatWebhookService
|
||||
|
||||
public function ensureSecret(): string
|
||||
{
|
||||
$existing = $this->sanitizeSecret((string) Controller::Config('chat_webhook_secret'));
|
||||
$existing = $this->sanitizeSecret(app(ConfigService::class)->getString('chat_webhook_secret'));
|
||||
if ($existing !== '') {
|
||||
return $existing;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,8 @@ class ConfigService
|
||||
}
|
||||
|
||||
/**
|
||||
* مقدار setting؛ اگر نبود از config/price_providers.php یا default پارامتر.
|
||||
* مقدار setting؛ اول سوپرادمین، بعد DB لوکال، بعد price_providers.php.
|
||||
* برای کلیدهای can_edit=0 همیشه از این مسیر (یا ConfigService) بخوانید — نه Setting::where مستقیم.
|
||||
*/
|
||||
public function get(string $key, $default = null)
|
||||
{
|
||||
|
||||
@@ -7,6 +7,7 @@ use App\Models\Customer;
|
||||
use App\Models\Price;
|
||||
use App\Models\PriceTrigger;
|
||||
use App\Models\Product;
|
||||
use App\Services\ConfigService;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class PriceTriggerService
|
||||
@@ -162,7 +163,7 @@ class PriceTriggerService
|
||||
$title = 'طلا';
|
||||
}
|
||||
|
||||
$shopName = (string) Controller::Config('name_fa');
|
||||
$shopName = (string) app(ConfigService::class)->getString('name_fa');
|
||||
$message = 'قیمت ' . $title . ' به ' . number_format((int) $current) . " رسید\n" . $shopName;
|
||||
|
||||
if (! Controller::isSmsNotifEnabled('sms_notif_price_trigger')) {
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Services\SmsBilling;
|
||||
use App\Models\Setting;
|
||||
use App\Models\SmsWallet;
|
||||
use App\Models\User;
|
||||
use App\Services\ConfigService;
|
||||
|
||||
class SmsAlertService
|
||||
{
|
||||
@@ -35,7 +36,7 @@ class SmsAlertService
|
||||
return;
|
||||
}
|
||||
|
||||
$appName = trim((string) Setting::where('key', 'name_fa')->value('value'));
|
||||
$appName = trim(app(ConfigService::class)->getString('name_fa'));
|
||||
if ($appName === '') {
|
||||
$appName = 'این نسخه';
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace App\Services\SmsBilling;
|
||||
|
||||
use App\Exceptions\SmsBlockedException;
|
||||
use App\Models\Setting;
|
||||
use App\Services\ConfigService;
|
||||
use App\Services\SmsBilling\Contracts\SmsProviderInterface;
|
||||
use App\Services\SmsBilling\Providers\CentralSmsApiProvider;
|
||||
use App\Services\SmsBilling\Providers\MeliPayamakProvider;
|
||||
@@ -188,12 +188,14 @@ class SmsGatewayService
|
||||
|
||||
private function buildProviderConfig(): array
|
||||
{
|
||||
$config = app(ConfigService::class);
|
||||
|
||||
return [
|
||||
'melipayamak_user' => Setting::where('key', 'melipayamak_user')->value('value'),
|
||||
'melipayamak_password' => Setting::where('key', 'melipayamak_password')->value('value'),
|
||||
'melipayamak_from' => Setting::where('key', 'melipayamak_from')->value('value'),
|
||||
'name_fa' => Setting::where('key', 'name_fa')->value('value'),
|
||||
'name_en' => Setting::where('key', 'name_en')->value('value'),
|
||||
'melipayamak_user' => $config->getString('melipayamak_user'),
|
||||
'melipayamak_password' => $config->getString('melipayamak_password'),
|
||||
'melipayamak_from' => $config->getString('melipayamak_from'),
|
||||
'name_fa' => $config->getString('name_fa'),
|
||||
'name_en' => $config->getString('name_en'),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Models\Setting;
|
||||
use App\Models\SmsLedger;
|
||||
use App\Models\SmsSendLog;
|
||||
use App\Models\SmsWallet;
|
||||
use App\Services\ConfigService;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
@@ -36,7 +37,7 @@ class SmsWalletService
|
||||
/** Billing/panel فعال است مگر sms_panel صریحاً false باشد. */
|
||||
public static function isBillingEnabled(): bool
|
||||
{
|
||||
$value = Setting::where('key', 'sms_panel')->value('value');
|
||||
$value = app(ConfigService::class)->getString('sms_panel');
|
||||
|
||||
if ($value === null || trim((string) $value) === '') {
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user