/** * 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(); } }