Ejemplo n.º 1
0
 public function setStateAttribute($value)
 {
     if (strlen($value) == 2) {
         $this->attributes['state_a2'] = strtoupper($value);
     } else {
         $operator = \Config::get('database.default') == 'pgsql' ? 'ilike' : 'like';
         $state = State::where('name', $operator, $value)->first();
         if ($state) {
             $this->attributes['state_a2'] = $state->a2;
         }
     }
     if (!empty($this->attributes['state_a2'])) {
         $this->attributes['state_name'] = Addresses::stateName($this->attributes['state_a2']);
     }
 }
Ejemplo n.º 2
0
 /**
  * @expectedException Illuminate\Database\Eloquent\ModelNotFoundException
  */
 public function testStateNotFoundException()
 {
     $this->assertEquals('Nevada', \Addresses::stateName('NV', 'CO'));
 }