nnjeim / world

A Laravel package which provides a list of the countries, states, cities, currencies, timezones and languages.
MIT License
748 stars 105 forks source link

cannot migrate on first install #18

Closed rogerad closed 2 years ago

rogerad commented 2 years ago

hi i just stated to download package and do install iam still on laravel 8 i got this message

php artisan migrate Migrating: 2020_07_07_055656_create_countries_table

ErrorException

foreach() argument must be of type array|object, null given

at vendor/nnjeim/world/src/Database/Migrations/2020_07_07_055656_create_countries_table.php:22 18▕ $table->string('iso2', 2); 19▕ $table->string('name'); 20▕ $table->tinyInteger('status')->default(1); 21▕ ➜ 22▕ foreach (config('world.migrations.countries.optional_fields') as $field => $value) { 23▕ if ($value['required']) { 24▕ $table->string($field, $value['length'] ?? null); 25▕ } 26▕ }

  +27 vendor frames 

28 artisan:37 Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

Process finished with exit code 1.

this might be related to the other issue today - please have a look

nnjeim commented 2 years ago

@rogerad Hi thanks for your input. I need to check with you if you have published the config file. please try php artisan vendor:publish --tag=world --force

kodjosama commented 2 years ago

The counties table sub_region field was renamed to the subregion field. But the sub_region field is still present in the countries JSON file. That is the issue. For now, I have made the subregion field optional

nnjeim commented 2 years ago

@rogerad @kodjosama This was fixed in the latest commit. I will publish a release right away. Please pull v1.1.9 sorry for the inconvenience

rogerad commented 1 year ago

Hi

I did publish the config file

In the meanwhile I am using another package

Thank you

On 21 Mar 2022, at 2:56 pm, Najm Njeim @.***> wrote:

@rogerad https://github.com/rogerad Hi thanks for your input. I need to check with you if you have published the config file. please try php artisan vendor:publish --tag=world --force

— Reply to this email directly, view it on GitHub https://github.com/nnjeim/world/issues/18#issuecomment-1073459759, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEOGOQCIGNDJNU3QAYWOZMDVA7XNVANCNFSM5RFJ7H7A. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you were mentioned.

fnagel commented 3 months ago

@nnjeim Still an issue with v1.1.30

I've just pulled your package using composer require nnjeim/world and installed it like described in the readme with php artisan world:install but this command failed:

Installing nnjeim/world...

   ErrorException 

  foreach() argument must be of type array|object, null given

  at vendor/nnjeim/world/src/Database/Migrations/2020_07_07_055656_create_countries_table.php:22
     18▕                        $table->string('iso2', 2);
     19▕                        $table->string('name');
     20▕                        $table->tinyInteger('status')->default(1);
     21▕
  ➜  22▕                        foreach (config('world.migrations.countries.optional_fields') as $field => $value) {
     23▕                                if ($value['required']) {
     24▕                                        $table->string($field, $value['length'] ?? null);
     25▕                                }
     26▕                        }

      +45 vendor frames 

  46  artisan:35
      Illuminate\Foundation\Console\Kernel::handle()

Any idea what is wrong?

fnagel commented 3 months ago

Ahh ok, the php artisan world:install command did work on the second run.