From 65d07ba64d45c77d2db16272710ec5702b34d641 Mon Sep 17 00:00:00 2001 From: George Halkiadakis Date: Tue, 25 Apr 2023 03:40:09 +0300 Subject: front-end: putting everything together --- public/app/models/cms/Course_model.php | 45 ++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'public/app/models/cms/Course_model.php') diff --git a/public/app/models/cms/Course_model.php b/public/app/models/cms/Course_model.php index 3d0ac1c..d8a8a0e 100644 --- a/public/app/models/cms/Course_model.php +++ b/public/app/models/cms/Course_model.php @@ -6,6 +6,10 @@ use \Registry; class Course_model { + /** COURSES + * ------------------------------------------------------------------------- + */ + /** get all categories * * raw table data (simplest SELECT) @@ -19,6 +23,21 @@ class Course_model { ); } + /** courses struct + * + * a super array with almost any info needed about courses + * + * @return (array) ['tree' => ..., 'breadcrumbs' => ... ] + */ + public static function courses_struct() + { + $tree = self::category_tree(); + return [ + 'tree' => $tree, + 'breadcrumbs' => self::breadcrumbs($tree) + ]; + } + /** constuct a category_tree * @@ -216,6 +235,32 @@ class Course_model { } + + + /** LESSONS + * ------------------------------------------------------------------------- + */ + + + /** lessons of course + * + * @param $course_id + */ + + public static function lessons_of_course($id) + { + // TODO: order results in some way + + return Registry::use('database')->runQuery( + "SELECT lesson.*, lesson_privilege.privilege_id FROM lesson + LEFT JOIN lesson_privilege ON lesson_privilege.lesson_id = lesson.id + WHERE lesson.status = 1 AND lesson.course_id = :id", + [':id' => $id] + ); + } + + + /** files * return all files * @param void -- cgit v1.2.3