- How do I install and set up eka/world in a Laravel project?
- Run `composer require eka/world`, publish the config with `php artisan vendor:publish --tag=world`, then execute `php artisan migrate` followed by `php artisan db:seed --class=WorldSeeder`. The seeder takes ~15 minutes to complete due to the dataset size.
- What Laravel versions does eka/world support?
- The package is designed for Laravel 8+ based on its age and Eloquent integration. No explicit version constraints are documented, but it aligns with Laravel’s modern architecture. Test thoroughly if using Laravel 9+.
- Can I fetch related data like states and cities when querying a country?
- Yes, use the `fields` parameter to include related data. For example, `World::countries(['fields' => 'states,cities'])` or `/api/countries?fields=states,cities` in API routes. This works for all entities (countries, states, cities).
- How do I search or filter data using the facade or API?
- Use the `filters` array in the facade (e.g., `['filters' => ['iso2' => 'FR']]`) or query parameters in API routes (e.g., `/api/countries?filters[iso2]=FR`). Supports search via `search` parameter (e.g., `?search=rom` for Rome).
- Is there a demo or live API I can test before installing?
- Yes, the package includes demo endpoints at [laravel-world.com](https://laravel-world.com). Try `/api/countries` or `/api/states?filters[country_code]=RO&fields=cities` to see live responses and API structure.
- What happens if the WorldSeeder fails during deployment?
- The package does not document a rollback strategy for failed seeds. If seeding fails, you may need to manually reset the database or handle conflicts in migrations. Consider staging seeding in CI/CD pipelines to avoid production downtime.
- Can I customize the dataset or add my own fields to entities?
- The package publishes config via `vendor:publish --tag=world`, allowing you to modify table names or default fields. However, there are no built-in hooks for adding custom attributes to entities like countries or cities.
- How often is the geospatial data updated, and can I sync it automatically?
- The package lacks automated update mechanisms. Data freshness depends on manual updates via new releases (last updated Dec 2023). For critical applications, consider integrating a third-party API (e.g., GeoNames) as a fallback or sync mechanism.
- Are there performance concerns with the API endpoints or facade?
- API endpoints return all fields by default, which may bloat responses. The facade does not support pagination or field filtering, unlike the API. For large datasets, optimize queries by specifying `fields` or consider caching responses.
- What alternatives exist for geospatial data in Laravel if eka/world isn’t maintained?
- Alternatives include Laravel packages like `spatie/laravel-countries` (simpler, country-focused) or `torann/laravel-geoip` (IP-based geolocation). For comprehensive datasets, consider integrating third-party APIs like GeoNames, Google Maps, or OpenStreetMap.