attachRepository = $attachRepositoryEloquent; } /** * @param Request $request * * @return mixed * @throws \Prettus\Repository\Exceptions\RepositoryException */ public function handleList(Request $request) { $this->attachRepository->pushCriteria(new AttachCriteria($request)); $this->attachRepository->setPresenter(AttachPresenter::class); return $this->attachRepository->searchAttachsByPage(); } /** * @param $id * * @return \Illuminate\Database\Eloquent\Model */ public function handleProfile($id) { $this->attachRepository->setPresenter(AttachPresenter::class); return $this->attachRepository->searchAttachBy($id); } /** * @param array $data * * @return mixed * @throws \Prettus\Validator\Exceptions\ValidatorException */ public function handleStore($data) { $attach = $this->attachRepository->create($data); return $attach; } /** * @param array $data * * @return mixed * @throws \Prettus\Validator\Exceptions\ValidatorException */ public function handleUpdate($data) { $attach = $this->attachRepository->update($data, $data['id']); return $attach; } /** * @param Request $request * * @return mixed * @throws \Prettus\Validator\Exceptions\ValidatorException */ public function handleDelete($id) { return $this->attachRepository->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->attachRepository->pushCriteria(new AttachCriteria($request)); return $this->attachRepository->all(['id', 'name']); } /** * @param Request $request * * @return mixed * @throws \Prettus\Repository\Exceptions\RepositoryException */ public function handleAll(Request $request) { $this->attachRepository->pushCriteria(new AttachCriteria($request)); $this->attachRepository->setPresenter(AttachPresenter::class); return $this->attachRepository->get(); } }