3 years ago

Laravel eloquent with multiple where and orWhere clauses

Posted 3 years ago by dilfdo

below is my search query i want to search data to followinig critieria

cusine or mealname = $cusine and country = $country and block_seller = 0

but currently it doesnt check the where clauses after orWhere, which means country and block_seller where clauses are not working.

please advice

            $meals = Meals::select('*')
                ->selectRaw("( 6371 * acos( cos( radians($latitude) ) *
                                   cos( radians( latitude ) )
                                   * cos( radians( longitude ) - radians($longitude)
                                   ) + sin( radians($latitude) ) *
                                   sin( radians( latitude ) ) )
                                 ) AS distance")

                ->where('cuisine', 'LIKE', "%$cuisine%")
                ->orWhere('meal_name', 'LIKE', "%$cuisine%")
                ->where('country', "$country")
                ->where('blocked_seller', 0)
                ->orderBy('distance', 'ASC')

Please sign in or create an account to participate in this conversation.