0
      $items = property::orderBy('id', 'desc')
    ->whereProperty_categoryAndProperty_for_sale_or_rent('condo', 'rent')
    ->whereProperty_categoryAndProperty_for_sale_or_rent('apartment', 'rent')
    ->paginate('9');

Hello please help me about this multiple select category there and two category Condo and Apartment and type rent in laravel. Thank you in advance.

0

1 Answer 1

1

Your query code's condition is

WHERE
property_category = 'condo' 
AND property_for_sale_or_rent.rent = 'rent' 
AND property_category = 'apartment' 
AND property_for_sale_or_rent.rent = 'rent'

so it will return no records.

You need to use where closure to get that:

$items = property::orderBy('id', 'desc')
    ->whereProperty_for_sale_or_rent('rent')
    ->where(function($q) {
        $q->whereProperty_category('condo')
          ->orWhere('property_category', 'apartment');
    })
    ->paginate('9');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.