Skip to content

Commit

Permalink
Bugfix: Lookup Countries
Browse files Browse the repository at this point in the history
  • Loading branch information
MGeurts committed Nov 3, 2024
1 parent 89e934c commit 6b58266
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions app/Countries.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace App;

use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Storage;

class Countries
{
Expand All @@ -14,10 +13,12 @@ class Countries
// -----------------------------------------------------------------------
public function __construct(string $locale = 'en')
{
if (Storage::exists(base_path('vendor') . '/stefangabos/world_countries/data/countries/' . $locale)) {
$this->countries = collect(require base_path('vendor') . '/stefangabos/world_countries/data/countries/' . $locale . '/countries.php');
$path = base_path('vendor/stefangabos/world_countries/data/countries/');

if (file_exists($path . $locale) && is_dir($path. $locale)) {
$this->countries = collect(require $path . $locale . '/countries.php');
} else {
$this->countries = collect(require base_path('vendor') . '/stefangabos/world_countries/data/countries/en/countries.php');
$this->countries = collect(require $path . 'en/countries.php');
}
}

Expand Down

0 comments on commit 6b58266

Please sign in to comment.