fix report
This commit is contained in:
@@ -215,6 +215,35 @@ class ConfigService
|
||||
return in_array($productId, $this->mainWalletProductIds(), true);
|
||||
}
|
||||
|
||||
/** اولین محصول فعال از `main_wallet_products` — نماینده کیف اصلی */
|
||||
public function mainWalletRepresentativeProduct(): ?Product
|
||||
{
|
||||
foreach ($this->mainWalletProductIds() as $productId) {
|
||||
$product = Product::query()->where('active', 1)->find($productId);
|
||||
if ($product) {
|
||||
return $product;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->mainWalletProductIds() as $productId) {
|
||||
$product = Product::query()->find($productId);
|
||||
if ($product) {
|
||||
return $product;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/** metal_id محصول نماینده کیف اصلی — پیشفرض ۱ (طلا) */
|
||||
public function mainWalletMetalId(): int
|
||||
{
|
||||
$product = $this->mainWalletRepresentativeProduct();
|
||||
$metalId = $product ? (int) ($product->metal_id ?? 0) : 0;
|
||||
|
||||
return $metalId > 0 ? $metalId : 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* شناسه محصول آبشده: اول settings، بعد const.
|
||||
* مقدار settings میتواند id عددی (مثل 13) یا reading_method (مثل estjt_...) باشد.
|
||||
|
||||
Reference in New Issue
Block a user