public function questionsbyCourseName($coursename)
 {
     /*
     Currently get all question
     */
     if (count(Course::all()) == 1) {
         return Question::active();
     }
     //if more than one course
     $subjects = Course::where('name', $coursename)->first()->subjects;
     $this->subjects = $subjects->pluck('id');
     $questions = Question::where(function ($query) {
         foreach ($this->subjects as $key => $value) {
             //you can use orWhere the first time, dosn't need to be ->where
             $query->orWhere('subject_id', '=', $value);
         }
     });
     return $questions;
 }
 public function get($typeid, $uuid)
 {
     // to get child element
     switch ($typeid) {
         case 0:
             //Course
             return Course::all();
         case 1:
             //Subject
             return Subject::where('ref_id', $uuid)->get();
         case 2:
             //Module
             return Module::where('ref_id', $uuid)->get();
         case 3:
             //Cha[ter]
             return Chapter::where('ref_id', $uuid)->get();
         case 4:
             //Topic
             return Topic::where('ref_id', $uuid)->get();
         default:
             # code...
             break;
     }
 }
 public function getcourses()
 {
     return Course::all();
 }