handle some performance for app

This commit is contained in:
2026-06-03 21:52:37 +03:30
parent 08a1ff85b5
commit aea3cbbc6e
4 changed files with 90 additions and 10 deletions
@@ -132,6 +132,7 @@ class WalletController extends Controller
$this->applyMetalTypeTransactionTitle($record);
$this->applyProductTransactionTitle($record);
$this->applyProductOrderDisplayFields($record);
$this->applyProductTransactionUnit($record);
}
return response()->json($records);
@@ -454,10 +455,28 @@ class WalletController extends Controller
}
if (!empty($record->wallet?->product)) {
$record->unit = $record->wallet->product->unit ?: 'عدد';
$record->unit = self::productQuantityUnit([
'unit' => $record->wallet->product->unit ?? null,
'direct_price' => $record->wallet->product->direct_price ?? null,
'group_type' => $record->wallet->product->group_type ?? null,
]);
}
}
private function applyProductTransactionUnit($record): void
{
$product = $record->wallet->product ?? $record->product ?? null;
if (!$product) {
return;
}
$record->unit = self::productQuantityUnit([
'unit' => $product->unit ?? null,
'direct_price' => $product->direct_price ?? null,
'group_type' => $product->group_type ?? null,
]);
}
private function isProductWalletTransaction($record): bool
{
return !empty($record->wallet?->product);