get(); Log::info(['User--->' => $user]); if ($user){ $lastLocation = $user->lastCoordinates; $minLat = $message['location']['latitude'] - 0.0005; $maxLat = $message['location']['latitude'] + 0.0005; $minLng = $message['location']['longitude'] - 0.0008; $maxLng = $message['location']['longitude'] + 0.0008; $newLat = false; $newLng = false; if (!$lastLocation->lat > $minLat && !$lastLocation->lat < $maxLat){ $newLat = $message['location']['latitude']; } if (!$lastLocation->lng > $minLng && !$lastLocation->lng < $maxLng){ $newLng = $message['location']['longitude']; } if($newLat || $newLng){ $newLocation = new Location(); $newLocation->lat = $newLat ?: $lastLocation->lat; $newLocation->lng = $newLng ?: $lastLocation->lng; $newLocation->user_id = $user->id; $newLocation->save(); Log::info('я сохранил новую координату'); } } Log::info('я ничего не сохранил'); } } }