Ejemplo n.º 1
0
 public static function findOrCreate($data)
 {
     $city = self::where('name', $data['city'])->first();
     if (count($city) <= 0) {
         $city = new City();
         $city->name = $data['city'];
         $city->state_id = State::findOrCreate($data)->id;
         $city->save();
     }
     return $city;
 }