Пример #1
0
 public function getModuleData(ModulesRequest $request)
 {
     if (!isset($_SESSION)) {
         session_start();
     }
     $courseId = $_SESSION['courseID'];
     if ($request->getModuleId()) {
         if ($request->getModuleItemId()) {
             return ModuleItem::with('content')->where(array('module_id' => $request->getModuleId(), 'module_item_id' => $request->getModuleItemId()))->first();
         } else {
             return Module::with('module_items.content')->where(array('module_id' => $request->getModuleId(), 'course_id' => $courseId))->first();
         }
     } else {
         //if no moduleId was found they must want all the modules
         $modules = Module::orderBy('parent_id', 'ASC')->orderBy('order', 'ASC')->with('module_items.content')->where(array('course_id' => $courseId))->get();
         return $modules;
     }
 }