Overview
The Course model manages course operations, including CRUD operations and various query methods for retrieving course data with related information. File:app/models/Course.php
Methods
getAll
Retrieves all courses with subject and teacher information. SQL Query:Returns array of all courses with related data
create
Creates a new course with a subject and teacher assignment.ID of the subject for this course
ID of the teacher assigned to this course
No return value (throws exception on failure)
delete
Deletes a course by ID.Course ID to delete
No return value (throws exception on failure)
getByTeacher
Retrieves all courses assigned to a specific teacher.Teacher ID to filter by
Returns array of courses for the specified teacher
belongsToTeacher
Checks if a specific course belongs to a specific teacher.Course ID to check
Teacher ID to verify ownership
Returns
true if the course belongs to the teacher, false otherwisegetForTimetable
Retrieves all courses formatted for timetable display with subject and teacher names. SQL Query:Returns array of courses ordered by subject name
find
Finds a specific course by ID.Course ID to find
Returns course record as associative array, or
false if not found