Inventory source check done
This commit is contained in:
parent
174ab21fa7
commit
e37bfabda7
|
|
@ -107,7 +107,7 @@ class CartController extends Controller
|
|||
* @return Array
|
||||
*/
|
||||
public function test() {
|
||||
$cart = $this->cart->findOneByField('id', 110);
|
||||
$cart = $this->cart->findOneByField('id', 144);
|
||||
|
||||
$items = $cart->items;
|
||||
|
||||
|
|
@ -120,15 +120,33 @@ class CartController extends Controller
|
|||
foreach($items as $item) {
|
||||
$inventories = $item->product->inventories;
|
||||
|
||||
foreach($inventories as $inventory) {
|
||||
$totalQty = $totalQty + $inventory->qty;
|
||||
$inventory_sources = $item->product->inventory_sources;
|
||||
|
||||
$totalQty = 0;
|
||||
foreach($inventory_sources as $inventory_source) {
|
||||
|
||||
if($inventory_source->status!=0) {
|
||||
foreach($inventories as $inventory) {
|
||||
$totalQty = $totalQty + $inventory->qty;
|
||||
}
|
||||
|
||||
array_push($allProdQty1, $totalQty);
|
||||
|
||||
$allProdQty[$item->product->id] = $totalQty;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
dd($allProdQty);
|
||||
|
||||
foreach ($items as $item) {
|
||||
$inventories = $item->product->inventory_sources->where('status', '=', '1');
|
||||
|
||||
foreach($inventories as $inventory) {
|
||||
dump($inventory->status);
|
||||
}
|
||||
|
||||
array_push($allProdQty1, $totalQty);
|
||||
|
||||
$allProdQty[$item->product->id] = $totalQty;
|
||||
}
|
||||
|
||||
dd($allProdQty, $allProdQty1);
|
||||
}
|
||||
}
|
||||
|
|
@ -9,4 +9,16 @@ class ProductInventory extends Model
|
|||
public $timestamps = false;
|
||||
|
||||
protected $fillable = ['qty', 'product_id', 'inventory_source_id'];
|
||||
|
||||
/**
|
||||
* Use by cart for
|
||||
* checking the
|
||||
* inventory source
|
||||
* status
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
// public function checkInventoryStatus() {
|
||||
// return $this->leftjoin('inventory_sources', 'inventory_sources.id', 'inventory_source_id')->select('status')->where('status', '=','1');
|
||||
// }
|
||||
}
|
||||
Loading…
Reference in New Issue