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