Inventory source check done

This commit is contained in:
prashant-webkul 2018-09-21 20:02:36 +05:30
parent 174ab21fa7
commit e37bfabda7
2 changed files with 38 additions and 8 deletions

View File

@ -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);
}
}

View File

@ -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');
// }
}