searchHistoryRepository = $searchHistoryRepositoryEloquent; } /** * @param Request $request * * @return mixed * @throws \Prettus\Repository\Exceptions\RepositoryException */ public function handleList(Request $request) { $this->searchHistoryRepository->pushCriteria(new SearchHistoryCriteria($request)); $this->searchHistoryRepository->setPresenter(SearchHistoryPresenter::class); return $this->searchHistoryRepository->searchSearchHistorysByPage(); } /** * @param $id * * @return \Illuminate\Database\Eloquent\Model */ public function handleProfile($id) { $this->searchHistoryRepository->setPresenter(SearchHistoryPresenter::class); return $this->searchHistoryRepository->searchSearchHistoryBy($id); } /** * @param array $data * * @return mixed * @throws \Prettus\Validator\Exceptions\ValidatorException */ public function handleStore($data) { $searchHistory = $this->searchHistoryRepository->create($data); return $searchHistory; } /** * @param array $data * * @return mixed * @throws \Prettus\Validator\Exceptions\ValidatorException */ public function handleUpdate($data) { $searchHistory = $this->searchHistoryRepository->update($data, $data['id']); return $searchHistory; } /** * @param Request $request * * @return mixed * @throws \Prettus\Validator\Exceptions\ValidatorException */ public function handleDelete($id) { return $this->searchHistoryRepository->delete($id); } /** * 搜索历史 * @param $type * @return mixed */ public function handleHistory($type) { return $this->searchHistoryRepository->where('guard', 'admins')->where('type', $type)->where('user_id', login_admin_id())->orderByDesc('id')->limit(5)->select(['keyword', 'id'])->get(); } }