Пример #1
0
 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'));
 }
Пример #2
0
 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']);
 }