private function getSchoolYears() { $schoolYears = SchoolYearQuery::create()->orderByYear('desc')->find(); $school_years_arr = ['' => '']; foreach ($schoolYears as $schoolYear) { $name = $schoolYear->__toString(); $id = $schoolYear->getId(); $school_years_arr[$id] = $name; } return $school_years_arr; }
/** * Create SchoolYear query. * */ protected function createQuery($array, $search) { $this->objects = SchoolYearQuery::create()->orderByYear('desc'); if (isset($array['Year']) && $array['Year'] !== "") { $this->objects->where("SchoolYear.year = ?", $array['Year']); } if (isset($array['Description']) && $array['Description'] !== "") { $this->objects->where("SchoolYear.description like '%" . $array['Description'] . "%'"); } if ($search) { session(['SchoolYear_filter' => $array]); } }
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 ChildSchoolYear object * * @param ConnectionInterface $con Optional Connection object. * @return ChildSchoolYear The associated ChildSchoolYear object. * @throws PropelException */ public function getSchoolYear(ConnectionInterface $con = null) { if ($this->aSchoolYear === null && $this->school_year_id !== null) { $this->aSchoolYear = ChildSchoolYearQuery::create()->findPk($this->school_year_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->aSchoolYear->addApplications($this); */ } return $this->aSchoolYear; }
/** * Performs an INSERT on the database, given a SchoolYear or Criteria object. * * @param mixed $criteria Criteria or SchoolYear 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(SchoolYearTableMap::DATABASE_NAME); } if ($criteria instanceof Criteria) { $criteria = clone $criteria; // rename for clarity } else { $criteria = $criteria->buildCriteria(); // build Criteria from SchoolYear object } if ($criteria->containsKey(SchoolYearTableMap::COL_ID) && $criteria->keyContainsValue(SchoolYearTableMap::COL_ID)) { throw new PropelException('Cannot insert a value for auto-increment primary key (' . SchoolYearTableMap::COL_ID . ')'); } // Set the correct dbName $query = SchoolYearQuery::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) { $schoolYear = SchoolYearQuery::create()->findPK($id); $schoolYear->delete(); flash()->success("DELETED"); session(['attribute' => \Lang::get('general.SCHOOL_YEAR')]); return redirect($this->main_page); }
private function getSchoolYearIdByDate() { $schoolYear = SchoolYearQuery::create()->where("SchoolYear.date_start <= ?", date('Y-m-d'))->where("SchoolYear.date_end >= ?", date('Y-m-d'))->findOne(); return $schoolYear->getId(); }
/** * Returns a new ChildSchoolYearQuery object. * * @param string $modelAlias The alias of a model in the query * @param Criteria $criteria Optional Criteria to build the query from * * @return ChildSchoolYearQuery */ public static function create($modelAlias = null, Criteria $criteria = null) { if ($criteria instanceof ChildSchoolYearQuery) { return $criteria; } $query = new ChildSchoolYearQuery(); if (null !== $modelAlias) { $query->setModelAlias($modelAlias); } if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
/** * 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 = ChildSchoolYearQuery::create(); $criteria->add(SchoolYearTableMap::COL_ID, $this->id); return $criteria; }