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

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -