/** * Create Course query. * */ protected function createQuery($array, $search) { $this->courses = CourseQuery::create()->orderByName(); if (isset($array['Name']) && $array['Name'] !== "") { $this->courses->where("course.name like '%" . $array['Name'] . "%'"); } if ($search) { session(['course_filter' => $array]); } }
private function getCourses() { $courses = CourseQuery::create()->orderByName()->find(); $courses_arr = ['' => '']; foreach ($courses as $course) { $name = $course->getName(); $id = $course->getId(); $courses_arr[$id] = $name; } return $courses_arr; }
public function getApplications($subject_id, $school_year_id, $course_id) { $subject = SubjectQuery::create()->findPk($subject_id); $course = CourseQuery::create()->findPk($course_id); $schoolYear = SchoolYearQuery::create()->findPk($school_year_id); $applications = ApplicationQuery::create()->where('Application.subject_id = ?', $subject_id)->where('Application.school_year_id = ?', $school_year_id)->join('Application.Student')->join('Application.Period')->where('Student.course_id = ?', $course_id)->select(['Student.FirstName', 'Student.LastName', 'Student.CourseId', 'Period.Name', 'ApplicationDate', 'ExamDate', 'ExamTime', 'ExamScore'])->find(); //dd($applications); $applications_arr = []; $cnt = 0; foreach ($applications as $key => $application) { $professor = $this->getProfessorName($subject_id, $application['Student.CourseId'], $school_year_id); $applications_arr[$professor][$cnt]['student'] = $application['Student.FirstName'] . ' ' . $application['Student.LastName']; $applications_arr[$professor][$cnt]['period'] = $application['Period.Name']; $applications_arr[$professor][$cnt]['application_date'] = $application['ApplicationDate']; $applications_arr[$professor][$cnt]['exam_datetime'] = $application['ExamDate'] . " " . $application['ExamTime']; $applications_arr[$professor][$cnt]['exam_score'] = isset($application['ExamScore']) && $application['ExamScore'] != 0 ? $application['ExamScore'] : ''; $cnt++; } $result['data'] = $applications_arr; $result['course'] = $course->__toString(); $result['subject'] = $subject->__toString(); $result['school_year'] = $schoolYear->__toString(); return $result; }
/** * Get the associated ChildCourse object * * @param ConnectionInterface $con Optional Connection object. * @return ChildCourse The associated ChildCourse object. * @throws PropelException */ public function getCourse(ConnectionInterface $con = null) { if ($this->aCourse === null && $this->course_id !== null) { $this->aCourse = ChildCourseQuery::create()->findPk($this->course_id, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aCourse->addStudents($this); */ } return $this->aCourse; }
/** * Builds a Criteria object containing the primary key for this object. * * Unlike buildCriteria() this method includes the primary key values regardless * of whether or not they have been modified. * * @throws LogicException if no primary key is defined * * @return Criteria The Criteria object containing value(s) for primary key(s). */ public function buildPkeyCriteria() { $criteria = ChildCourseQuery::create(); $criteria->add(CourseTableMap::COL_ID, $this->id); return $criteria; }
/** * Returns a new ChildCourseQuery object. * * @param string $modelAlias The alias of a model in the query * @param Criteria $criteria Optional Criteria to build the query from * * @return ChildCourseQuery */ public static function create($modelAlias = null, Criteria $criteria = null) { if ($criteria instanceof ChildCourseQuery) { return $criteria; } $query = new ChildCourseQuery(); if (null !== $modelAlias) { $query->setModelAlias($modelAlias); } if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
/** * Performs an INSERT on the database, given a Course or Criteria object. * * @param mixed $criteria Criteria or Course object containing data that is used to create the INSERT statement. * @param ConnectionInterface $con the ConnectionInterface connection to use * @return mixed The new primary key. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doInsert($criteria, ConnectionInterface $con = null) { if (null === $con) { $con = Propel::getServiceContainer()->getWriteConnection(CourseTableMap::DATABASE_NAME); } if ($criteria instanceof Criteria) { $criteria = clone $criteria; // rename for clarity } else { $criteria = $criteria->buildCriteria(); // build Criteria from Course object } if ($criteria->containsKey(CourseTableMap::COL_ID) && $criteria->keyContainsValue(CourseTableMap::COL_ID)) { throw new PropelException('Cannot insert a value for auto-increment primary key (' . CourseTableMap::COL_ID . ')'); } // Set the correct dbName $query = CourseQuery::create()->mergeWith($criteria); // use transaction because $criteria could contain info // for more than one table (I guess, conceivably) return $con->transaction(function () use($con, $query) { return $query->doInsert($con); }); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $course = CourseQuery::create()->findPK($id); $course->delete(); flash()->success("DELETED"); session(['attribute' => \Lang::get('general.COURSE')]); return redirect($this->main_page); }