diff --git a/app/Http/Controllers/Admin/WalletController.php b/app/Http/Controllers/Admin/WalletController.php index a32405b..45faf85 100644 --- a/app/Http/Controllers/Admin/WalletController.php +++ b/app/Http/Controllers/Admin/WalletController.php @@ -578,7 +578,9 @@ class WalletController extends Controller $walletTableWith = [ 'customer:id,name,mobile', 'fund:id,title', - 'product:id,metal_id,unit,amount,group_type,trade_by_quantity,direct_price,title', + 'product' => static function ($q) { + $q->withTrashed()->select(['id', 'metal_id', 'unit', 'amount', 'group_type', 'trade_by_quantity', 'direct_price', 'title']); + }, ]; $sumRows = (clone $sumQuery)->with($walletTableWith)->get(); diff --git a/app/Services/WalletBalanceService.php b/app/Services/WalletBalanceService.php index fa194af..ed09f97 100644 --- a/app/Services/WalletBalanceService.php +++ b/app/Services/WalletBalanceService.php @@ -380,16 +380,23 @@ class WalletBalanceService private function lineProduct(mixed $line): ?object { - if (is_object($line) && isset($line->product)) { + if (is_object($line) && isset($line->product) && $line->product) { return $line->product; } - if (is_array($line) && isset($line['product'])) { + if (is_array($line) && isset($line['product']) && $line['product']) { $product = $line['product']; return is_object($product) ? $product : (object) $product; } + $productId = (int) ($this->lineValue($line, 'product_id') ?? 0); + if ($productId > 0) { + return Product::withTrashed() + ->select(['id', 'title', 'metal_id', 'unit', 'amount', 'group_type', 'trade_by_quantity', 'direct_price']) + ->find($productId); + } + return null; }