/** * 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); }
/** * 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)]); }
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); }
/** * 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]); }
/** * 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')); }
/** * @param $lessonId * @return \Illuminate\Database\Eloquent\Collection|static[] */ public function getTags($lessonId) { $tags = $lessonId ? Lesson::find($lessonId)->tags : Tag::all(); return $tags; }