where('class_id', $classId) ->where('subject', $subject) ->orderBy('unit_number', 'ASC') ->orderBy("CAST(SUBSTRING_INDEX(chapter_name, '.', 1) AS UNSIGNED)", 'ASC', false) ->orderBy('chapter_name', 'ASC') ->findAll(); } }