nodeRepository = $nodeRepositoryEloquent; } /** * @param Request $request * * @return mixed * @throws \Prettus\Repository\Exceptions\RepositoryException */ public function handleList(Request $request) { $this->nodeRepository->pushCriteria(new NodeCriteria($request)); $this->nodeRepository->setPresenter(NodePresenter::class); return $this->nodeRepository->searchNodesByPage(); } /** * @param $id * * @return \Illuminate\Database\Eloquent\Model */ public function handleProfile($id) { $this->nodeRepository->setPresenter(NodePresenter::class); return $this->nodeRepository->searchNodeBy($id); } /** * @param array $data * * @return mixed * @throws \Prettus\Validator\Exceptions\ValidatorException */ public function handleStore($data) { $node = $this->nodeRepository->create($data); return $node; } /** * @param array $data * * @return mixed * @throws \Prettus\Validator\Exceptions\ValidatorException */ public function handleUpdate($data) { $node = $this->nodeRepository->update($data, $data['id']); return $node; } /** * @param Request $request * * @return mixed * @throws \Prettus\Validator\Exceptions\ValidatorException */ public function handleDelete($id) { return $this->nodeRepository->delete($id); } public function handleUserDelete($id) { $node = $this->nodeRepository->find($id); if ($node['user_id'] != login_user_id()) abort(ResponseCodeEnum::SERVICE_OPERATION_ERROR, '非法操作'); return $this->nodeRepository->delete($id); } }