/**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $lesson = new Lesson();
     $lesson->name = $request->name;
     $lesson->setDescriptionAttribute($request->description);
     $lesson->github = $request->github;
     $lesson->video = $request->video;
     $lesson->download = $request->download;
     $lesson->length = $request->length;
     $lesson->series_id = $request->series_id;
     $lesson->section_id = $request->section_id;
     $lesson->save();
     $series = Series::find($lesson->series_id);
     $series->length = (int) $series->length + (int) $request->length;
     $series->lessons = $series->lessons + 1;
     $series->save();
     return redirect('/admin/lessons/create');
 }
 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'));
 }
Exemple #3
0
 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.');
 }
 public function show(Request $request, $slug)
 {
     $lesson = Lesson::with('series')->where('slug', $slug)->firstOrFail();
     $series = Series::with(['sections' => function ($query) {
         $query->orderBy('series_order', 'asc');
     }])->find($lesson->section->series_id);
     //dd($lesson);
     if ($request->user() and $request->user()->series->contains($lesson->section->series_id) || $request->user()->stripe_active == 1) {
         $user_lessons = Auth::user()->lessons;
         return view('lesson.show', compact('lesson', 'series', 'user_lessons'));
     } else {
         return redirect('purchase/' . $series->slug);
     }
     return redirect('login')->withErrors('You must be logged in to view this lesson.');
 }
Exemple #5
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $lesson = Lesson::findOrFail($id);
     $courses = Course::all();
     return view('admin.lesson.show', compact('lesson', 'courses'));
 }
Exemple #6
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Lesson::truncate();
     factory(Lesson::class, 2000)->create();
 }