php - Getting results from first element of foreach -
there many matching credentials inside table inserted foreach loop getting results first foreach element. how fix that?
foreach($matches $match) { $object = $match->object; $sales->whereraw("match (`object`) against (?)", array($object)); if($match->colourbase == '1') { $sales->where('colour', '=', 'cc'); $sales->orwhere('colour', '=', 'cc+dd'); if($match->maxprice) { $sales->where('price', '<=', $match->maxprice); } if($match->minprice) { $sales->where('price', '>=', $match->minprice); } } } $results = $sales->orderby('sales.updated_at', 'asc')->get();
@update
this how $matches
$matches = match::where('peopleid', '=', $id)->get();
if want 1 record use first()
function. no need use foreach. :)
$matches = match::where('peopleid', '=', $id)->first();
Comments
Post a Comment