code: public static function findOrNew($id)
      {
          $model = static::find($id);
          if (is_null($model)) {
              $model = static::createInstance();
              $model->setId($id);
          }
          return $model;
      }
docs: Find a model by its primary key or return new model.
  
  @param mixed $id
  @return static