예제 #1
0
 public function index()
 {
     $labs = Labs::all();
     /*
      $feature = [];
      $subjects = Subjects::all();
      foreach ($subjects as $one) {
      $rel = SubjectsLabs::select('*')
      ->where('subject_id', $one->id)->get();
      $lab_feature = [
      'id' => -1,
      'qtd' => 0
      ];
      foreach ($rel as $r) {
      $n = Log::where(['lab_id' => $r->lab_id])->count();
      if ($n > $lab_feature['qtd']) {
      $lab_feature['id'] = $r->lab_id;
      $lab_feature['qtd'] = $n;
      }
      }
      if ($lab_feature['id'] >= 0)
      $feature[$one->name] = Labs::find($lab_feature['id']);
      }
     */
     $users = DB::table('users')->get();
     $category_id = App::getLocale() == 'pt' ? 5 : 2;
     $all_courses = array_map(function ($item) {
         return (array) $item;
     }, DB::connection('moodle')->table('mdl_course')->where('category', $category_id)->where('visible', '1')->get());
     $courses = [];
     $qtd = 5 <= count($all_courses) ? '5' : count($all_courses);
     $nums = [];
     $i = 0;
     do {
         //$rand = rand(0, $qtd - 1);
         // if (!array_search($rand, $courses)) {
         array_push($courses, $all_courses[$i]);
         $i++;
         //}
     } while ($i < $qtd);
     return view('home', ['labs' => $labs, 'courses' => $courses]);
 }
예제 #2
0
 public function labs_page()
 {
     $labs = Labs::all();
     return view('all_labs', compact('labs'));
 }