| Total Complexity | 3 |
| Total Lines | 51 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | class Course extends DataLayer |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * Course constructor. |
||
| 11 | */ |
||
| 12 | public function __construct() |
||
| 13 | { |
||
| 14 | parent::__construct("courses", ["name"], "id", false); |
||
| 15 | } |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @return array|null |
||
| 19 | */ |
||
| 20 | public function studentsWhoPrefer(): ?array |
||
| 21 | { |
||
| 22 | $students = new Student(); |
||
| 23 | return $this |
||
| 24 | ->select("*, courses.name as course_name") |
||
| 25 | ->join( |
||
| 26 | $students, |
||
| 27 | 'courses.id', '=', 'students.preferred_course') |
||
| 28 | ->where( |
||
| 29 | 'courses.id = :id', |
||
| 30 | "id={$this->id}") |
||
|
|
|||
| 31 | ->limit(5) |
||
| 32 | ->fetch(true); |
||
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * @return array|null |
||
| 37 | */ |
||
| 38 | public function studentsThatFinished(): ?array |
||
| 58 | } |
||
| 59 | } |