first commit
This commit is contained in:
commit
d21491ac94
18
.editorconfig
Normal file
18
.editorconfig
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
indent_size = 4
|
||||||
|
indent_style = space
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
trim_trailing_whitespace = false
|
||||||
|
|
||||||
|
[*.{yml,yaml}]
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[docker-compose.yml]
|
||||||
|
indent_size = 4
|
38
.gitattributes
vendored
Normal file
38
.gitattributes
vendored
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
* text=auto eol=lf
|
||||||
|
|
||||||
|
*.blade.php diff=html
|
||||||
|
*.css diff=css
|
||||||
|
*.html diff=html
|
||||||
|
*.md diff=markdown
|
||||||
|
*.php diff=php
|
||||||
|
|
||||||
|
/.github export-ignore
|
||||||
|
CHANGELOG.md export-ignore
|
||||||
|
.styleci.yml export-ignore
|
||||||
|
|
||||||
|
# Ignorar archivos de configuración y herramientas de desarrollo
|
||||||
|
.editorconfig export-ignore
|
||||||
|
.prettierrc.json export-ignore
|
||||||
|
.prettierignore export-ignore
|
||||||
|
.eslintrc.json export-ignore
|
||||||
|
|
||||||
|
# Ignorar node_modules y dependencias locales
|
||||||
|
node_modules/ export-ignore
|
||||||
|
vendor/ export-ignore
|
||||||
|
|
||||||
|
# Ignorar archivos de build
|
||||||
|
npm-debug.log export-ignore
|
||||||
|
|
||||||
|
# Ignorar carpetas de logs y caché
|
||||||
|
storage/logs/ export-ignore
|
||||||
|
storage/framework/ export-ignore
|
||||||
|
|
||||||
|
# Ignorar carpetas de compilación de frontend
|
||||||
|
public/build/ export-ignore
|
||||||
|
dist/ export-ignore
|
||||||
|
|
||||||
|
# Ignorar archivos de CI/CD
|
||||||
|
.github/ export-ignore
|
||||||
|
.gitlab-ci.yml export-ignore
|
||||||
|
.vscode/ export-ignore
|
||||||
|
.idea/ export-ignore
|
10
.gitignore
vendored
Normal file
10
.gitignore
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
/node_modules
|
||||||
|
/vendor
|
||||||
|
/.vscode
|
||||||
|
/.nova
|
||||||
|
/.fleet
|
||||||
|
/.phpactor.json
|
||||||
|
/.phpunit.cache
|
||||||
|
/.phpunit.result.cache
|
||||||
|
/.zed
|
||||||
|
/.idea
|
16
.prettierignore
Normal file
16
.prettierignore
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# Dependencias de Composer y Node.js
|
||||||
|
/vendor/
|
||||||
|
/node_modules/
|
||||||
|
|
||||||
|
# Caché y logs
|
||||||
|
/storage/
|
||||||
|
*.log
|
||||||
|
*.cache
|
||||||
|
|
||||||
|
# Archivos del sistema
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# Configuración de editores
|
||||||
|
.idea/
|
||||||
|
.vscode/
|
29
.prettierrc.json
Normal file
29
.prettierrc.json
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"arrowParens": "avoid",
|
||||||
|
"bracketSpacing": true,
|
||||||
|
"bracketSameLine": true,
|
||||||
|
"htmlWhitespaceSensitivity": "css",
|
||||||
|
"insertPragma": false,
|
||||||
|
"jsxSingleQuote": true,
|
||||||
|
"printWidth": 120,
|
||||||
|
"proseWrap": "preserve",
|
||||||
|
"quoteProps": "as-needed",
|
||||||
|
"requirePragma": false,
|
||||||
|
"semi": true,
|
||||||
|
"singleQuote": true,
|
||||||
|
"tabWidth": 4,
|
||||||
|
"trailingComma": "none",
|
||||||
|
"useTabs": false,
|
||||||
|
"endOfLine": "lf",
|
||||||
|
"embeddedLanguageFormatting": "auto",
|
||||||
|
"overrides": [
|
||||||
|
{
|
||||||
|
"files": [
|
||||||
|
"resources/assets/**/*.js"
|
||||||
|
],
|
||||||
|
"options": {
|
||||||
|
"semi": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
39
CHANGELOG.md
Normal file
39
CHANGELOG.md
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
# 📜 CHANGELOG - Laravel Geolocation API
|
||||||
|
|
||||||
|
Este documento sigue el formato [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
|
|
||||||
|
## [0.1.0] - ALPHA - 2024-03-05
|
||||||
|
|
||||||
|
### ✨ Added (Agregado)
|
||||||
|
- 🚀 Primera versión alpha de la librería.
|
||||||
|
- 🔹 Implementación inicial de [funcionalidad clave 1].
|
||||||
|
- 🔹 Integración con [dependencia o servicio principal].
|
||||||
|
- 🔹 Soporte para [Laravel/Vuexy Admin, si aplica].
|
||||||
|
|
||||||
|
### 🛠 Changed (Modificado)
|
||||||
|
- 🔄 Optimización de [código o estructura interna].
|
||||||
|
|
||||||
|
### 🐛 Fixed (Correcciones)
|
||||||
|
- 🐞 Correcciones iniciales en [migraciones, modelos, servicios, etc.].
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📅 Próximos Cambios Planeados
|
||||||
|
- 📊 **Mejoras en [feature futuro]**.
|
||||||
|
- 🏪 **Compatibilidad con [Laravel 11, Vuexy, etc.]**.
|
||||||
|
- 📍 **Integración con [API o funcionalidad esperada]**.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**📌 Nota:** Esta es una versión **ALPHA**, aún en desarrollo.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🔄 Sincronización de Cambios
|
||||||
|
Este `CHANGELOG.md` se actualiza primero en nuestro repositorio principal en **[Tea - Koneko Git](https://git.koneko.mx/koneko/laravel-geolocation-api)** y luego se refleja en GitHub.
|
||||||
|
Los cambios recientes pueden verse antes en **Tea** que en **GitHub** debido a la sincronización automática.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
📅 Última actualización: **2024-03-05**.
|
||||||
|
|
9
CONTRIBUTING.md
Normal file
9
CONTRIBUTING.md
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
## 🔐 Acceso al Repositorio Privado
|
||||||
|
|
||||||
|
Nuestro servidor Git en **Tea** tiene un registro cerrado. Para contribuir:
|
||||||
|
|
||||||
|
1. Abre un **Issue** en [GitHub](https://github.com/koneko-mx/laravel-geolocation-api/issues) indicando tu interés en contribuir.
|
||||||
|
2. Alternativamente, envía un correo a **admin@koneko.mx** solicitando acceso.
|
||||||
|
3. Una vez aprobado, recibirás una invitación para registrarte y clonar el repositorio.
|
||||||
|
|
||||||
|
Si solo necesitas acceso de lectura, puedes clonar la versión pública en **GitHub**.
|
9
LICENSE
Normal file
9
LICENSE
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2025 koneko
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
104
README.md
Normal file
104
README.md
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
# 📦 Laravel Geolocation API
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://koneko.mx" target="_blank"> <img src="https://git.koneko.mx/Koneko-ST/koneko-st/raw/branch/main/logo-images/horizontal-05.png" width="400" alt="Koneko Soluciones Tecnológicas Logo"> </a>
|
||||||
|
</p>
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://koneko.mx"><img src="https://img.shields.io/badge/Website-koneko.mx-blue" alt="Sitio Web"></a>
|
||||||
|
<a href="https://packagist.org/packages/koneko/laravel-geolocation-api"><img src="https://img.shields.io/packagist/v/koneko/laravel-geolocation-api" alt="Latest Stable Version"></a>
|
||||||
|
<a href="https://packagist.org/packages/koneko/laravel-geolocation-api"><img src="https://img.shields.io/packagist/l/koneko/laravel-geolocation-api" alt="License"></a>
|
||||||
|
<a href="https://git.koneko.mx/koneko"><img src="https://img.shields.io/badge/Git%20Server-Koneko%20Git-orange" alt="Servidor Git"></a>
|
||||||
|
<a href="https://github.com/koneko-mx/laravel-geolocation-api/actions/workflows/tests.yml"><img src="https://github.com/koneko-mx/laravel-geolocation-api/actions/workflows/tests.yml/badge.svg" alt="Build Status"></a>
|
||||||
|
<a href="https://github.com/koneko-mx/laravel-geolocation-api/issues"><img src="https://img.shields.io/github/issues/koneko/laravel-geolocation-api" alt="Issues"></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📌 Descripción
|
||||||
|
|
||||||
|
**Laravel Geolocation API** es un paquete de Laravel diseñado para [descripción breve de la funcionalidad].
|
||||||
|
|
||||||
|
### ✨ Características:
|
||||||
|
- 🔹 Funcionalidad clave 1
|
||||||
|
- 🔹 Funcionalidad clave 2
|
||||||
|
- 🔹 Funcionalidad clave 3
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📦 Instalación
|
||||||
|
|
||||||
|
Instalar vía **Composer**:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
composer require koneko/laravel-geolocation-api
|
||||||
|
```
|
||||||
|
|
||||||
|
Publicar archivos de configuración y migraciones (si aplica):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
php artisan vendor:publish --tag=laravel-geolocation-api-config
|
||||||
|
php artisan migrate
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🚀 Uso básico
|
||||||
|
|
||||||
|
```php
|
||||||
|
use Koneko\NombreLibreria\Models\Model;
|
||||||
|
|
||||||
|
$model = Model::create([
|
||||||
|
'campo1' => 'Valor',
|
||||||
|
'campo2' => 'Otro valor',
|
||||||
|
]);
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📚 Configuración adicional
|
||||||
|
|
||||||
|
Si necesitas personalizar la configuración del módulo, publica el archivo de configuración:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
php artisan vendor:publish --tag=laravel-geolocation-api-config
|
||||||
|
```
|
||||||
|
|
||||||
|
Esto generará `config/laravel-geolocation-api.php`, donde puedes modificar valores predeterminados.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🛠 Dependencias
|
||||||
|
|
||||||
|
Este paquete requiere las siguientes dependencias:
|
||||||
|
- Laravel 11
|
||||||
|
- Dependencias específicas de la librería
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🌍 Repositorio Principal y Sincronización
|
||||||
|
|
||||||
|
Este repositorio es una **copia sincronizada** del repositorio principal alojado en **[Tea - Koneko Git](https://git.koneko.mx/koneko/laravel-geolocation-api)**.
|
||||||
|
|
||||||
|
### 🔄 Sincronización con GitHub
|
||||||
|
- **Repositorio Principal:** [git.koneko.mx](https://git.koneko.mx/koneko/laravel-geolocation-api)
|
||||||
|
- **Repositorio en GitHub:** [github.com/koneko-mx/laravel-geolocation-api](https://github.com/koneko-mx/laravel-geolocation-api)
|
||||||
|
- **Los cambios pueden reflejarse primero en Tea antes de GitHub.**
|
||||||
|
|
||||||
|
### 🤝 Contribuciones
|
||||||
|
Si deseas contribuir:
|
||||||
|
1. Puedes abrir un **Issue** en [GitHub Issues](https://github.com/koneko-mx/laravel-geolocation-api/issues).
|
||||||
|
2. Para Pull Requests, **preferimos contribuciones en Tea**. Contacta a `admin@koneko.mx` para solicitar acceso.
|
||||||
|
|
||||||
|
⚠️ **Nota:** Algunos cambios pueden tardar en reflejarse en GitHub, ya que este repositorio se actualiza automáticamente desde Tea.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🏅 Licencia
|
||||||
|
|
||||||
|
Este paquete es de código abierto bajo la licencia [MIT](LICENSE).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
Hecho con ❤️ por <a href="https://koneko.mx">Koneko Soluciones Tecnológicas</a>
|
||||||
|
</p>
|
100
Services/GeolocationApiService.php
Normal file
100
Services/GeolocationApiService.php
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Koneko\GeolocationApi\Services;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
|
||||||
|
class GeolocationApiService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Obtiene la configuración del servicio de geolocalización.
|
||||||
|
*/
|
||||||
|
protected function getConfig()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'enabled' => Setting::getValue('geolocation.enabled', false),
|
||||||
|
'provider' => Setting::getValue('geolocation.provider', 'locationiq'),
|
||||||
|
'api_keys' => json_decode(Setting::getValue('geolocation.api_keys', '{}'), true),
|
||||||
|
'language' => Setting::getValue('geolocation.language', 'es'),
|
||||||
|
'country_bias' => Setting::getValue('geolocation.country_bias', 'MX'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtiene coordenadas a partir de una dirección.
|
||||||
|
*/
|
||||||
|
public function getCoordinates(string $address, ?string $provider = null)
|
||||||
|
{
|
||||||
|
$config = $this->getConfig();
|
||||||
|
|
||||||
|
if (!$config['enabled']) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$provider = $provider ?: $config['provider'];
|
||||||
|
$apiKey = $config['api_keys'][$provider] ?? null;
|
||||||
|
|
||||||
|
if (!$apiKey) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return match ($provider) {
|
||||||
|
'locationiq' => $this->getLocationIQCoordinates($address, $apiKey, $config),
|
||||||
|
'google' => $this->getGoogleCoordinates($address, $apiKey, $config),
|
||||||
|
default => null,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Llama a la API de LocationIQ para obtener coordenadas.
|
||||||
|
*/
|
||||||
|
protected function getLocationIQCoordinates(string $address, string $apiKey, array $config)
|
||||||
|
{
|
||||||
|
$url = "https://us1.locationiq.com/v1/search.php";
|
||||||
|
|
||||||
|
$response = Http::get($url, [
|
||||||
|
'key' => $apiKey,
|
||||||
|
'q' => $address,
|
||||||
|
'format' => 'json',
|
||||||
|
'accept-language' => $config['language'],
|
||||||
|
'countrycodes' => $config['country_bias']
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($response->successful()) {
|
||||||
|
$data = $response->json();
|
||||||
|
|
||||||
|
return [
|
||||||
|
'lat' => $data[0]['lat'] ?? null,
|
||||||
|
'lng' => $data[0]['lon'] ?? null,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Llama a la API de Google Maps para obtener coordenadas.
|
||||||
|
*/
|
||||||
|
protected function getGoogleCoordinates(string $address, string $apiKey, array $config)
|
||||||
|
{
|
||||||
|
$url = "https://maps.googleapis.com/maps/api/geocode/json";
|
||||||
|
|
||||||
|
$response = Http::get($url, [
|
||||||
|
'key' => $apiKey,
|
||||||
|
'address' => $address,
|
||||||
|
'language' => $config['language'],
|
||||||
|
'region' => $config['country_bias']
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($response->successful()) {
|
||||||
|
$data = $response->json();
|
||||||
|
|
||||||
|
return [
|
||||||
|
'lat' => $data['results'][0]['geometry']['location']['lat'] ?? null,
|
||||||
|
'lng' => $data['results'][0]['geometry']['location']['lng'] ?? null,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
28
composer.json
Normal file
28
composer.json
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
"name": "koneko/laravel-geolocation-api",
|
||||||
|
"description": "Laravel Geolocation API, un servicico para obtener coordenadas GPS a partir de una dirección.",
|
||||||
|
"keywords": ["laravel", "koneko", "framework", "geolocation", "api", "gps"],
|
||||||
|
"type": "library",
|
||||||
|
"license": "MIT",
|
||||||
|
"require": {
|
||||||
|
"php": "^8.2",
|
||||||
|
"laravel/framework": "^11.31"
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Koneko\\GeolocationApi\\": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Arturo Corro Pacheco",
|
||||||
|
"email": "arturo@koneko.mx"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"source": "https://github.com/koneko-mx/laravel-geolocation-api",
|
||||||
|
"issues": "https://github.com/koneko-mx/laravel-geolocation-api/issues"
|
||||||
|
},
|
||||||
|
"minimum-stability": "dev",
|
||||||
|
"prefer-stable": true
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user