} return \Response::json(['data' => $data]); }); Route::get('/search', function () { // filtration algorithm stuff goes here $skillids = array(); $skilllist = json_decode(\Input::get("skills"), true); foreach ($skilllist as $d) { $skillids[] = (int) $d["value"]; } // location filter with fix 1200 (1.2 degrees) threshold $latitude = \Input::get('location_latitude'); $longitude = \Input::get('location_longitude'); $skilbaseids = DB::table('candidate_to_skill')->whereIn("skill_id", $skillids)->lists('user_id'); Log::info($skilbaseids); $userall = \Motibu\Models\Candidate::all(); $userIds = array(); if ($latitude != "" && $longitude != "") { foreach ($userall as $key => $d) { // $distance = getDistance($latitude,$longitude,$d->location_latitude,$d->location_longitude); $earth_radius = 6371; $dLat = deg2rad($d->location_latitude - $latitude); $dLon = deg2rad($d->location_longitude - $longitude); $a = sin($dLat / 2) * sin($dLat / 2) + cos(deg2rad($latitude)) * cos(deg2rad($d->location_latitude)) * sin($dLon / 2) * sin($dLon / 2); $c = 2 * asin(sqrt($a)); $distance = $earth_radius * $c; if ($distance <= 100) { $userIds[] = $d->user_id; } } }