public function index() { $studentsCount = User::count(); $lessons = Lesson::where('published', 1)->orderBy('id', 'desc')->take(30)->get(); $available = Series::where('for_sale', 1)->where('preorder', 0)->get(); $presale = Series::where('for_sale', 1)->where('preorder', 1)->get(); //$series = Series::where('for_sale', 1)->orderBy('id')->take(10)->get(); return view('welcome', compact('studentsCount', 'available', 'presale', 'lessons')); }
public function show(Request $request, $courseSlug, $slug) { if ($request->user() and $request->user()->hasRole('student')) { $lesson = Lesson::where('slug', $slug)->firstOrFail(); $courses = Course::where('published', 1)->get(); return view('lesson.show', compact('lesson', 'courses')); } else { return redirect('purchase'); } return redirect('login')->withErrors('You must be logged in to view this lesson.'); }