コード例 #1
0
 /**
  * Display Bus arrival times of the given bus stop
  * Check user is logged or not, if not return login page
  * Otherwise get the bus arrival time and bus stop info
  *
  * @return a view
  */
 public function getBusArrivalTimes($stopID)
 {
     if (!Auth::guest()) {
         $busLib = new BusServiceLib();
         $busRoutes = $busLib->getBusArrivalTimes($stopID);
         $bushalt = BusStop::where('bus_stop_id', $stopID)->first();
         return view("businfo/busStopInfo", ['busRoutes' => $busRoutes, 'busHaltInfo' => $bushalt]);
     } else {
         return redirect("auth/login");
     }
 }
コード例 #2
0
 /**
  * delete certain bus stop from database
  *
  * @param $halte_id
  * @return \Illuminate\Http\JsonResponse
  */
 public function deleteBusStop($halte_id)
 {
     $busStopModel = new BusStop();
     $response = array();
     try {
         $busStopModel->where('halte_id', '=', $halte_id)->delete();
         $response['code'] = 200;
         $response['data']['msg'] = 'bus stop has been successfully deleted from database';
     } catch (\Exception $e) {
         $response['code'] = 500;
         $response['data']['msg'] = 'failed to delete bus stop. Make sure halte id is correct.';
     }
     header("Access-Control-Allow-Origin: *");
     return response()->json($response);
 }
 /**
  * check if bus has arrived to nearest bus stop on its route
  * todo: detect if bus has arrived to certain bus stop
  */
 public function checkBusLocationStatus()
 {
     $this->filterNearestBusStop();
     if ($this->nearestBusStop['routes'][0]['legs'][0]['distance']['value'] <= 15) {
         $arrivalEstimationModel = new ArrivalEstimation();
         $arrivalEstimationModel->where('halte_id_tujuan', '=', $this->nearestBusStop['halte_id'])->delete();
         $busStop = new BusStop();
         $busStop->where('halte_id', '=', $this->nearestBusStop['halte_id'])->update(['last_bus' => $this->plat_nomor]);
         $busStopHistoryModel = new BusStopHistory();
         $busStopHistoryModel->plat_nomor = $this->plat_nomor;
         $busStopHistoryModel->halte_id = $this->nearestBusStop['halte_id'];
         $busStopHistoryModel->rute_id = $this->rute_id;
         $busStopHistoryModel->save();
     }
 }
コード例 #4
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy(BusStop $bus_stop)
 {
     $bus_stop->delete();
     return redirect('admin/bus_stops')->with(['flash_message' => 'Parada deletada.', 'flash_message_level' => 'success']);
 }