Пример #1
0
 public function getUsers(Request $request)
 {
     $lat = $request->get('lat');
     $long = $request->get('long');
     $schools = School::all();
     $users = new \Illuminate\Database\Eloquent\Collection();
     for ($i = 0; $i < $schools->count(); $i++) {
         $schoolLat = $schools->get($i)->latitude;
         $schoolLong = $schools->get($i)->longitude;
         if ($this->haversine($lat, $long, $schoolLat, $schoolLong) < 50) {
             $users->push($schools->get($i)->usersNotVoted($request->get('CurrentUser')->id));
         }
     }
     return Response::json(['users' => $users->collapse()], 200);
 }