lundi 30 janvier 2017

How to create dynamic query?

I have 7 records. 6 of them have selling and 1 is rent. In array i get this:

array:2 [▼
  0 => "Selling"
  1 => "Rent"
]

But when i foreach that in result i get 4 and not 7. Any suggestion how can i fix this. Im trying to create dynamic query so if i enter one more thing that i dont need to change here anything.

if(is_array($option)){
    foreach($option as $o){
        $q->orWhere('name', 'like', $o);
    }

  }
   else{
      $q->orWhere('name', 'like', $option);
   }



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire