I am trying to store values to array using foreach loop, here is my code
public function priceRegulation(){
$prices = Price::where('hotel_id', $this->id);
$lowerPrices = [];
if($prices->count() > 0){
foreach ($prices as $price) {
$lowerPrices[] = $price;
}
if(sizeof($lowerPrices) < 1){
return false;
} else{
return true;
}
} else{
return 'empty';
}
}
I have also tried setting $lowerPrices to 0 (int type) and increment it through foreach, but result was the same variable remaind at 0. I have tested if statements and they work fine. The problem is with foreach it basically does nothing. I am using Laravel Framework.
Any help is welcome!
Regards