mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 05:04:07 -08:00
Refactor for fewer queries
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
5ebf0ed2b2
commit
ebf6ce6980
|
@ -38,7 +38,7 @@ class AccessoriesTransformer
|
||||||
'purchase_cost' => Helper::formatCurrencyOutput($accessory->purchase_cost),
|
'purchase_cost' => Helper::formatCurrencyOutput($accessory->purchase_cost),
|
||||||
'order_number' => ($accessory->order_number) ? e($accessory->order_number) : null,
|
'order_number' => ($accessory->order_number) ? e($accessory->order_number) : null,
|
||||||
'min_qty' => ($accessory->min_amt) ? (int) $accessory->min_amt : null,
|
'min_qty' => ($accessory->min_amt) ? (int) $accessory->min_amt : null,
|
||||||
'remaining_qty' => (int) $accessory->numRemaining(),
|
'remaining_qty' => (int) ($accessory->qty - $accessory->checkouts_count),
|
||||||
'checkouts_count' => $accessory->checkouts_count,
|
'checkouts_count' => $accessory->checkouts_count,
|
||||||
'created_by' => ($accessory->adminuser) ? [
|
'created_by' => ($accessory->adminuser) ? [
|
||||||
'id' => (int) $accessory->adminuser->id,
|
'id' => (int) $accessory->adminuser->id,
|
||||||
|
@ -60,7 +60,7 @@ class AccessoriesTransformer
|
||||||
|
|
||||||
$permissions_array['user_can_checkout'] = false;
|
$permissions_array['user_can_checkout'] = false;
|
||||||
|
|
||||||
if ($accessory->numRemaining() > 0) {
|
if (($accessory->qty - $accessory->checkouts_count) > 0) {
|
||||||
$permissions_array['user_can_checkout'] = true;
|
$permissions_array['user_can_checkout'] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue