Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
* develop:
  command handle/fire for compatibility for older laravel versions
  Update README.md
  Update MigrationCommand.php
  Update MigrationCommand.php
  Update countries.json
  Update README.md
  Update README.md
  Update composer.json
  Update composer.json
  Fix: PHP 7.2 E_WARNING about sizeof()

# Conflicts:
#	src/Webpatser/Countries/Countries.php
  • Loading branch information
webpatser committed May 16, 2018
2 parents f41444d + 860e1ab commit 032562f
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 41 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ Add `webpatser/laravel-countries` to `composer.json`.

Run `composer update` to pull down the latest version of Country List.

**If you're using Laravel 5.5, you don't have to edit `app/config/app.php`.**

Edit `app/config/app.php` and add the `provider` and `filter`

'providers' => [
Expand All @@ -40,7 +38,6 @@ You can start by publishing the configuration. This is an optional step, it cont
Next generate the migration file:

$ php artisan countries:migration
$ composer dump-autoload

It will generate the `<timestamp>_setup_countries_table.php` migration and the `CountriesSeeder.php` seeder. To make sure the data is seeded insert the following code in the `seeds/DatabaseSeeder.php`

Expand All @@ -52,4 +49,4 @@ You may now run it with the artisan migrate command:

$ php artisan migrate --seed

After running this command the filled countries table will be available
After running this command the filled countries table will be available
12 changes: 1 addition & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,5 @@
"support" : {
"source" : "https://github.com/webpatser/laravel-countries",
"issues" : "https://github.com/webpatser/laravel-countries/issues"
},
"extra": {
"laravel": {
"providers": [
"Webpatser\\Countries\\CountriesServiceProvider"
],
"aliases": {
"Countries": "Webpatser\\Countries\\CountriesFacade"
}
}
}
}
}
10 changes: 5 additions & 5 deletions src/Webpatser/Countries/Countries.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ protected function getCountries()

/**
* Returns one country
*
*
* @param string $id The country id
*
* @return array
Expand All @@ -63,9 +63,9 @@ public function getOne($id)

/**
* Returns a list of countries
*
*
* @param string sort
*
*
* @return array
*/
public function getList($sort = null)
Expand All @@ -75,7 +75,7 @@ public function getList($sort = null)

//Sorting
$validSorts = [
'capital',
'capital',
'citizenship',
'country-code',
'currency',
Expand Down Expand Up @@ -103,7 +103,7 @@ public function getList($sort = null)
return 1;
} else {
return strcasecmp($a[$sort], $b[$sort]);
}
}
});
}

Expand Down
4 changes: 2 additions & 2 deletions src/Webpatser/Countries/Models/countries.json
Original file line number Diff line number Diff line change
Expand Up @@ -1706,7 +1706,7 @@
"citizenship":"Guadeloupean",
"country-code":"312",
"currency":"euro",
"currency_code":"EUR",
"currency_code":"EUR ",
"currency_sub_unit":"cent",
"full_name":"Guadeloupe",
"iso_3166_2":"GP",
Expand Down Expand Up @@ -3665,7 +3665,7 @@
"citizenship":"San Marinese",
"country-code":"674",
"currency":"euro",
"currency_code":"EUR",
"currency_code":"EUR ",
"currency_sub_unit":"cent",
"full_name":"Republic of San Marino",
"iso_3166_2":"SM",
Expand Down
33 changes: 14 additions & 19 deletions src/commands/MigrationCommand.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php

namespace Webpatser\Countries;

Expand Down Expand Up @@ -31,13 +31,13 @@ public function __construct()
$app = app();
$app['view']->addNamespace('countries',substr(__DIR__,0,-8).'views');
}

/**
* Execute the console command.
*
* @return void
*/
public function fire()
public function handle()
{
$this->line('');
$this->info('The migration process will create a migration file and a seeder for the countries list');
Expand All @@ -53,16 +53,14 @@ public function fire()
{
$this->line('');

if (version_compare(app()->version(), '5.5.0', '<')) {
$this->call('optimize', []);
}
$this->call('optimize', []);

$this->line('');

$this->info( "Migration successfully created!" );
}
else{
$this->error(
$this->error(
"Coudn't create migration.\n Check the write permissions".
" within the app/database/migrations directory."
);
Expand All @@ -72,16 +70,6 @@ public function fire()
}
}

/**
* Alias fire method.
*
* @return void
*/
public function handle()
{
$this->fire();
}

/**
* Get the console command options.
*
Expand Down Expand Up @@ -109,7 +97,7 @@ protected function createMigration()

$seconds = 0;

foreach ($migrationFiles as $migrationFile => $outputFile) {
foreach ($migrationFiles as $migrationFile => $outputFile) {
if (sizeof(glob($migrationFile)) == 0) {
$migrationFile = str_replace('*', date('Y_m_d_His', strtotime('+' . $seconds . ' seconds')), $migrationFile);

Expand Down Expand Up @@ -143,5 +131,12 @@ protected function createMigration()

return true;
}


/**
* BC for older laravel versions
*/
public function fire()
{
$this->handle();
}
}

0 comments on commit 032562f

Please sign in to comment.