Esempio n. 1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $branche = new Station();
     $branche->user_id = Auth::user()->id;
     $branche->airport_id = $request->airport;
     if ($branche->save()) {
         return response()->json(['success' => true, 'airport' => Airport::find($request->airport)]);
     }
 }
Esempio n. 2
0
 public function getDistance($airport1_id = Null, $airport2_id = Null)
 {
     $airport1 = Airport::find($airport1_id);
     $airport2 = Airport::find($airport2_id);
     if ($airport1 and $airport2) {
         $y1 = $airport1->lon;
         $y2 = $airport2->lon;
         $x1 = $airport1->lat;
         $x2 = $airport2->lat;
         $distance = acos(sin($x1 = deg2rad($x1)) * sin($x2 = deg2rad($x2)) + cos($x1) * cos($x2) * cos(deg2rad($y2) - deg2rad($y1))) * 6378.137;
         $distance = (int) $distance;
         return $distance;
     }
 }