chapterRepository = $chapterRepositoryEloquent; } /** * @param Request $request * * @return mixed * @throws \Prettus\Repository\Exceptions\RepositoryException */ public function handleList(Request $request) { $this->chapterRepository->pushCriteria(new ChapterCriteria($request)); $this->chapterRepository->setPresenter(ChapterPresenter::class); return $this->chapterRepository->searchChaptersByPage(); } /** * @param $id * * @return \Illuminate\Database\Eloquent\Model */ public function handleProfile($id) { $this->chapterRepository->setPresenter(ChapterPresenter::class); return $this->chapterRepository->searchChapterBy($id); } /** * @param array $data * * @return mixed * @throws \Prettus\Validator\Exceptions\ValidatorException */ public function handleStore($data) { $chapter = $this->chapterRepository->create($data); return $chapter; } /** * @param array $data * * @return mixed * @throws \Prettus\Validator\Exceptions\ValidatorException */ public function handleUpdate($data) { $chapter = $this->chapterRepository->update($data, $data['id']); return $chapter; } /** * @param Request $request * * @return mixed * @throws \Prettus\Validator\Exceptions\ValidatorException */ public function handleDelete($id) { return $this->chapterRepository->delete($id); } /** * 批量删除 * @param $ids * @return mixed */ public function handleBatchDelete($ids) { return $this->chapterRepository->whereIn('id', $ids)->delete(); } /** * 选项 * @param Request $request * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator|\Illuminate\Support\Collection|mixed * @throws \Prettus\Repository\Exceptions\RepositoryException */ public function handleSelectOptions(Request $request) { $this->chapterRepository->pushCriteria(new ChapterCriteria($request)); return $this->chapterRepository->all(['id', 'title']); } /** * @param Request $request * * @return mixed * @throws \Prettus\Repository\Exceptions\RepositoryException */ public function handleAll(Request $request) { $this->chapterRepository->pushCriteria(new ChapterCriteria($request)); $this->chapterRepository->setPresenter(ChapterPresenter::class); return $this->chapterRepository->get(); } }