commentRepository = $commentRepositoryEloquent; } /** * @param Request $request * * @return mixed * @throws \Prettus\Repository\Exceptions\RepositoryException */ public function handleList(Request $request) { $this->commentRepository->pushCriteria(new CommentCriteria($request)); $this->commentRepository->setPresenter(CommentPresenter::class); return $this->commentRepository->searchCommentsByPage(); } /** * @param $id * * @return \Illuminate\Database\Eloquent\Model */ public function handleProfile($id) { $this->commentRepository->setPresenter(CommentPresenter::class); return $this->commentRepository->searchCommentBy($id); } /** * @param array $data * * @return mixed * @throws \Prettus\Validator\Exceptions\ValidatorException */ public function handleStore($data) { $comment = $this->commentRepository->create($data); return $comment; } /** * @param array $data * * @return mixed * @throws \Prettus\Validator\Exceptions\ValidatorException */ public function handleUpdate($data) { $comment = $this->commentRepository->update($data, $data['id']); return $comment; } /** * @param Request $request * * @return mixed * @throws \Prettus\Validator\Exceptions\ValidatorException */ public function handleDelete($id) { return $this->commentRepository->delete($id); } /** * @param Request $request * * @return mixed * @throws \Prettus\Repository\Exceptions\RepositoryException */ public function handleAll(Request $request) { $this->commentRepository->pushCriteria(new CommentCriteria($request)); $this->commentRepository->setPresenter(CommentPresenter::class); return $this->commentRepository->get(); } /** * 批量删除 * @param $ids * @return mixed */ public function handleBatchDelete($ids) { return $this->commentRepository->whereIn('id', $ids)->delete(); } public function handleUserDelete($id) { $node = $this->commentRepository->find($id); if ($node['user_id'] != login_user_id()) abort(ResponseCodeEnum::SERVICE_OPERATION_ERROR, '非法操作'); return $this->commentRepository->delete($id); } }