コード例 #1
0
 /**
  * Determine if the user is authorized to make this request.
  *
  * @return bool
  */
 public function authorize()
 {
     $lesson = Lesson::find($this->input('lesson_id'));
     $product = $lesson->product;
     $users = $product->owner()->lists('id')->toArray();
     return in_array(Auth::id(), $users);
 }
コード例 #2
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $lesson = Lesson::find($id);
     if (!$lesson) {
         return $this->respondNotFound('Lesson does not exist');
     }
     return $this->respond(['data' => $this->lessonTransformer->transform($lesson)]);
 }
コード例 #3
0
 public function lesson($id)
 {
     $lesson = Lesson::find($id);
     if (empty($lesson)) {
         Flash::error('Lesson not found');
         return redirect('/');
     }
     return view('site.lessons.show')->with('lesson', $lesson);
 }
コード例 #4
0
 /**
  * Handle the command.
  *
  * @param  StoreUserLessonResultCommand  $command
  * @return void
  */
 public function handle(StoreUserLessonResultCommand $command)
 {
     $user = User::find($command->userId);
     $lesson = Lesson::find($command->lessonId);
     $user->lessons()->save($lesson, ['score' => $command->score]);
 }
コード例 #5
0
 /**
  * Remove the specified Lesson from storage.
  *
  * @param  int $id
  *
  * @return Response
  */
 public function destroy($id)
 {
     /** @var Lesson $lesson */
     $lesson = Lesson::find($id);
     if (empty($lesson)) {
         Flash::error('Lesson not found');
         return redirect(route('admin.lessons.index'));
     }
     $lesson->delete();
     Flash::message('Lesson deleted successfully.');
     return redirect(route('admin.lessons.index'));
 }
コード例 #6
0
 /**
  * @param $lessonId
  * @return \Illuminate\Database\Eloquent\Collection|static[]
  */
 public function getTags($lessonId)
 {
     $tags = $lessonId ? Lesson::find($lessonId)->tags : Tag::all();
     return $tags;
 }