Пример #1
0
 public function show(Request $request, $courseSlug, $slug)
 {
     $lesson = Lesson::with('course')->where('slug', $slug)->firstOrFail();
     if ($request->user() and $request->user()->hasRole('starter') and $request->user()->hasCourse($lesson->course->slug)) {
         return view('lesson.show', compact('lesson'));
     } else {
         return redirect('purchase');
     }
     return redirect('login')->withErrors('You must be logged in to view this lesson.');
 }
Пример #2
0
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(LessonUpdateRequest $request, $id)
 {
     $lesson = Lesson::findOrFail($id);
     $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->course_id = $request->course_id;
     $lesson->save();
     return redirect()->route('admin.lesson.edit', [$lesson->id])->withSuccess('Lesson successfully edited.');
 }