code: public function readCourse($id) {
          if ($id == 0) {
              $courses = $this->store->get_records('course',array());
  
              //since get_records will return the ids as Key values for the array,
              //just use key to find the first id in the course table for the index page
              $id = key($courses);
          }
          $model = $this->readObject($id, 'course');
          $model->url = $this->cfg->wwwroot.($id > 0 ? '/course/view.php?id=' . $id : '');
          return $model;
      }
docs: Reads a course from the store with the given id.
  @param String $id
  @return PhpObj