repository = $repository; $this->validator = $validator; } public function store(Request $request) { $this->validate($request, $this->validator->getRules(ValidatorInterface::RULE_CREATE)); try { $data = $request->only(array_keys($this->validator->getRules(ValidatorInterface::RULE_CREATE))); $data['user_id'] = login_user_id(); $comment = $this->repository->create($data); return Response::success($comment); } catch (\Exception $e) { return $this->errorStore($e); } } public function videoComments($video_id) { $comments = $this->repository->where('course_video_id', $video_id)->paginate(request('per_page', self::PAGE_NUM)); return Response::success($this->repository->parserResult($comments)); } public function courseComments($course_id) { $comments = $this->repository->where('course_id', $course_id)->paginate(request('per_page', self::PAGE_NUM)); return Response::success($this->repository->parserResult($comments)); } }