/** * Show the application dashboard to the user. * * @return Response */ public function index() { if ($this->adminAuth()) { $categories = Category::take(10)->get(); $users = User::where('type', 'teacher')->take(5)->get(); $courses = Course::take(10)->get(); return view('adminHome', compact('courses', 'users', 'categories')); } elseif ($this->teacherAuth()) { $courses = Course::where('user_id', Auth::User()->id)->take(10)->get(); return view('teacherHome', compact('courses')); } elseif ($this->studentAuth()) { $courseStudents = CourseStudent::where('user_id', Auth::User()->id)->take(10)->get(); return view('studentHome', compact('courseStudents')); } //return view('home'); }
public function courses($page = 1) { $this->data['current_page'] = $page; $limit = 8; $offset = ($page - 1) * $limit; $this->data['courses'] = Course::take($limit)->skip($offset)->get(); $total = Course::all()->count(); $this->data['total'] = $total; $num_pages = ceil($total / $limit); $this->data['num_pages'] = $num_pages; $landing = Landing::all(); $this->data['landing'] = $landing; $this->data['current_tab'] = 7; return view('manage.courses', $this->data); }