- How do I install Laravel ID Countries and set up the countries table?
- Run `composer require ferdirn/laravel-id-countries:dev-master`, register the service provider and facade in `config/app.php`, then generate the migration and seeder with `php artisan countries:migration`. Add the seeder to `DatabaseSeeder.php` and run `php artisan migrate --seed` to populate the table.
- Does this package support Laravel 10 or newer?
- The package is tested with Laravel 5.5+, but since it uses `dev-master`, check the `composer.json` constraints for compatibility. If issues arise, verify PHP 8.0+ support and test thoroughly, as breaking changes may occur in newer Laravel versions.
- Can I customize the countries table name or fields?
- Yes, publish the config with `php artisan config:publish ferdirn/laravel-id-countries` to modify the table name or fields. The default table name is `countries`, but you can rename it if needed. Ensure your migration aligns with the updated config.
- What data does the package include for each country?
- The package provides country name, ISO 3-letter and 2-letter codes, capital city, currency, and calling code. This covers most use cases for forms, profiles, or location-based features, but note that currency/calling code updates may require manual intervention.
- Is the data up-to-date, and how do I handle changes like new countries or currency updates?
- The package includes static data, so updates (e.g., new countries, currency changes) require manual intervention. Validate data against ISO 3166-1 or other standards post-installation. For critical apps, consider forking the package or setting up a manual update process.
- Will this package work with PostgreSQL or SQLite?
- Yes, the package is database-agnostic and works with any Laravel-supported database, including PostgreSQL and SQLite. Ensure your database collation supports UTF-8 (e.g., `utf8mb4_unicode_ci` for MySQL) to handle special characters in country names or capitals.
- Are there alternatives to this package for country data in Laravel?
- Yes, alternatives include `league/iso3166` (for ISO 3166-1 data) or `spatie/laravel-countries` (which offers more granular control and API-based updates). Evaluate whether you need static seeding (this package) or dynamic data (API-driven alternatives).
- How do I query the countries table in Laravel?
- Use Eloquent to query the `countries` table. For example, fetch a country by ISO code: `Countries::where('iso_code', 'US')->first()`. The package provides a `Countries` facade for easy access, and you can extend the model for custom logic if needed.
- Does the package include tests, and how can I verify its functionality?
- The package’s README lacks test examples, so manually verify functionality by running `php artisan migrate --seed` and querying the `countries` table. Test edge cases like special characters in names or capitals, and compare data against ISO standards if accuracy is critical.
- What should I do if the countries table already exists in my database?
- If the `countries` table exists, either drop it or rename your existing table before running the migration. The package does not handle conflicts automatically, so back up your data first. After setup, you can manually merge existing data if needed.