private function getFleetGpsData($updateDatetime = null, $vehicleId = null) { $gpsQuery = Gps::where('company_id', Auth::user()['company_id']); if (!empty($updateDatetime)) { $gpsQuery = $gpsQuery->where('created_at', '>', $updateDatetime); } if (!empty($vehicleId)) { $gpsQuery = $gpsQuery->where('vehicle_id', $vehicleId); } $gpsQuery = $gpsQuery->orderBy('created_at', 'asc')->get(); $gpsData = []; if (!empty($gpsQuery)) { foreach ($gpsQuery as $gps) { $objGps = new \stdClass(); $objGps->latitude = HelperRepository::manageEmptyValue($gps->latitude); $objGps->longitude = HelperRepository::manageEmptyValue($gps->longitude); $gpsData[$gps->vehicle_id] = $objGps; } } return $gpsData; }
public function getLocalizationData($idVehicle) { $localizationData = Gps::where('vehicle_id', $idVehicle)->orderBy('id', 'desc')->first(); return $localizationData; }