flatten code

This commit is contained in:
imanghafoori 2019-04-03 18:09:13 +03:30
parent 86198676a1
commit 07806c44fc
2 changed files with 40 additions and 38 deletions

View File

@ -37,7 +37,9 @@ class OrderItemInventoryRepository extends Repository
$product = $orderItem->type == 'configurable' ? $orderItem->child->product : $orderItem->product;
if ($product) {
if (!$product) {
return ;
}
$inventories = $product->inventory_sources()->orderBy('priority', 'asc')->get();
foreach ($inventories as $inventorySource) {
@ -73,6 +75,6 @@ class OrderItemInventoryRepository extends Repository
'qty' => $sourceQuantity
]);
}
}
}
}

View File

@ -89,9 +89,9 @@ class OrderItemRepository extends Repository
$product = $orderItem->type == 'configurable' ? $orderItem->child->product : $orderItem->product;
if (! $product) {
if (! $product)
return;
}
$orderedInventory = $product->ordered_inventories()
->where('channel_id', $orderItem->order->channel->id)