C
C
cadaver2016-10-29 16:41:37
Laravel
cadaver, 2016-10-29 16:41:37

Laravel - How to make "and+and" condition instead of "or+or" in query?

$places = Place::where(DB::raw('(price/people)'), '<=', $price)->where('people', '>=', $people)->whereHas('metros', function ($query) use ($metros) {
        $query->whereIn('metro_id', $metros);
      })->whereHas('comforts', function ($query) use ($comforts) {
        $query->whereIn('comfort_id', $comforts);
      })->orderBy(DB::raw('(price/people)'), 'desc')->skip($offset)->take($take)->get();

now filtering by $comforts, i.e. outputs any where it is. how to do where only requested $comforts are present?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Aksentiev, 2016-10-29
@Sanasol

The idea itself is here stackoverflow.com/a/11636084/1603055
Then transfer it to Laravel somehow.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question