lundi 30 janvier 2017

How to use orWhere when i have an array and other fields with only one value?

I want to make filter. In view i have two inputs like this:

<input type="checkbox" id="test" value=""  name="prop_category[]"/>

  <input type="checkbox" id="toggle-on" value="" class="singleChb" name="publishing_types" @if ($index == 1) {!! "checked" !!}

First input can have multiple values and second can have only only one value.

Now in controller i have this:

  foreach($options as $key => $option) {
            if($key != "search" &&
                $key != "page"  &&
                $key != "starterResult"  &&
                $key != "totalResult") {

                $query->whereHas($key,function($q) use($option){
                    $q->orWhere('name', 'like', $option);
                });
            }
        }

In $options i get an array for first input and for second i get one value. How can i use that now orWhere to check all of that selected values from first input. Now im able to check only for one value, and not for array. Any suggetion?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2kjszKO
via IFTTT

Aucun commentaire:

Enregistrer un commentaire