public function testCountries() { $this->assertGreaterThan(220, count(\Addresses::getCountries())); // should be like 240 or so $this->assertEquals(Country::byCode('US')->first(), Country::byCode('USA')->first()); $this->assertEquals('Canada', \Addresses::countryName('CA')); }
public function setCountryAttribute($value) { if (strlen($value) == 2) { $this->attributes['country_a2'] = strtoupper($value); } else { $operator = \Config::get('database.default') == 'pgsql' ? 'ilike' : 'like'; $country = Country::where('name', $operator, $value)->first(); if ($country) { $this->attributes['country_a2'] = $country->a2; } } $this->attributes['country_name'] = Addresses::countryName($this->attributes['country_a2']); }