update_5_2_2019

This commit is contained in:
Frank John Begornia
2019-05-02 22:45:44 +08:00
parent c982366dbd
commit c39fb0a2a4
10 changed files with 114 additions and 96 deletions

View File

@@ -120,12 +120,24 @@ class TeamStoreController extends Controller {
$teams_array = $m->getTeams($product_array[0]->Id);
$sizes_array = $m->getSizes();
if($product_array[0]->ProductAvailableQty != null){
$soldQty = $m->getSoldQty($product_array[0]->Id);
// var_dump($soldQty);
// echo $product_array[0]->ProductAvailableQty;
$availableQty = $product_array[0]->ProductAvailableQty - $soldQty[0]->SoldQty;
}else{
// echo 'no qty';
$availableQty = null;
}
// $product_array[0]->ProductAvailableQty
return view('teamstore-sublayouts.product-details')
->with('store_array', $store_array)
->with('product_array', $product_array)
->with('thumbnails_array', $thumbnails_array)
->with('teams_array', $teams_array)
->with('sizes_array', $sizes_array);
->with('sizes_array', $sizes_array)
->with('available_qty', $availableQty);
}

View File

@@ -134,5 +134,13 @@ class TeamStoreModel extends Model {
->update($data);
return $i;
}
function getSoldQty($productId){
$i = DB::table('orders')->select(DB::raw('SUM(Quantity) AS SoldQty'))
->where('ProductId', $productId)
->get();
return $i;
}
}