setting changed 2
This commit is contained in:
@@ -29,7 +29,9 @@ class SettingsController extends Controller
|
||||
if ($setting) {
|
||||
$setting->value = $request->value;
|
||||
$setting->description = $request->description;
|
||||
$setting->is_active = $request->is_active;
|
||||
if ($request->has('is_active')) {
|
||||
$setting->is_active = filter_var($request->is_active, FILTER_VALIDATE_BOOLEAN) ? 1 : 0;
|
||||
}
|
||||
$setting->title_fa = $request->title_fa ?? '';
|
||||
if (Setting::hasTypeColumn()) {
|
||||
$setting->type = $request->type ?? '';
|
||||
@@ -41,7 +43,7 @@ class SettingsController extends Controller
|
||||
$setting->title_fa = $request->title_fa ?? '';
|
||||
$setting->value = $request->value;
|
||||
$setting->description = $request->description;
|
||||
$setting->is_active = $request->is_active;
|
||||
$setting->is_active = filter_var($request->is_active ?? true, FILTER_VALIDATE_BOOLEAN) ? 1 : 0;
|
||||
$setting->can_edit = 1;
|
||||
if (Setting::hasTypeColumn()) {
|
||||
$setting->type = $request->type ?? '';
|
||||
|
||||
@@ -152,7 +152,13 @@ class Controller extends BaseController
|
||||
}
|
||||
public static function Config($name)
|
||||
{
|
||||
return Setting::where('key',$name)->first()->value ?? false;
|
||||
$row = Setting::where('key', $name)->first();
|
||||
|
||||
if ($row && $row->is_active && $row->value !== null && $row->value !== '') {
|
||||
return $row->value;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected static function metalTypeSettingValue(): ?string
|
||||
|
||||
@@ -10,7 +10,6 @@ use App\Models\Setting;
|
||||
use App\Models\ConfigStatic;
|
||||
use App\Models\Customer;
|
||||
use App\Services\MontzarService;
|
||||
use App\Services\EtehadiePriceService;
|
||||
use App\Services\ZaarboxPriceService;
|
||||
use App\Models\Price;
|
||||
use App\Models\PriceCandle;
|
||||
@@ -331,15 +330,12 @@ class ReportController extends Controller
|
||||
if ($pr_product && !$closed) {
|
||||
if ($priceProvider === 'main_product') {
|
||||
if (Product::hasStoredPriceColumns()) {
|
||||
app(EtehadiePriceService::class)->syncProductFromApi($pr_product->fresh());
|
||||
app(ZaarboxPriceService::class)->syncProductFromApi($pr_product->fresh());
|
||||
$pr_product->refresh();
|
||||
$pr_price = (float) $pr_product->price + (float) ($pr_product->price_profit ?? 0);
|
||||
} else {
|
||||
$apiUrl = $config->getString('zaarbox_api_url', '')
|
||||
?: $config->getString('etehadie_api_url', 'https://price.zaarbox.ir/api/free');
|
||||
$live = app(EtehadiePriceService::class)->fetchLiveOrderPrice(
|
||||
$pr_product->reading_method,
|
||||
$apiUrl
|
||||
$live = app(ZaarboxPriceService::class)->fetchLiveOrderPrice(
|
||||
$pr_product->reading_method
|
||||
);
|
||||
$pr_price = (float) ($live['order_price'] ?? 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user