public function flash_amount($productId)
{
$data['product_promotion'] = Offer::where('started_date','<=',Carbon::now())->where('end_date','>=',Carbon::now())->with('product_promotion')->first();
if ($data['product_promotion']) {
foreach($data['product_promotion']->product_promotion as $promotion){
if($promotion->product_id == $productId){
$exist = 1;
}
}
if($exist == 1){
foreach($data['product_promotion']->product_promotion as $promotion){
if($promotion->product_id == $productId){
return $promotion->flash_amount;
}
}
}
else{
return null;
}
}
else
{
return null;
}
}
0 Comments