repository = $search_log; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\B2buy\SearchLog\Repositories\Criteria\SearchLogResourceCriteria::class); } /** * Display a list of search_log. * * @return Response */ public function index(SearchLogRequest $request) { return $this->repository ->setPresenter(\B2buy\SearchLog\Repositories\Presenter\SearchLogPresenter::class) ->paginate(); } /** * Display search_log. * * @param Request $request * @param Model $search_log * * @return Response */ public function show(SearchLogRequest $request, SearchLog $search_log) { return $search_log->setPresenter(\B2buy\SearchLog\Repositories\Presenter\SearchLogListPresenter::class); ; } /** * Create new search_log. * * @param Request $request * * @return Response */ public function store(SearchLogRequest $request) { try { $data = $request->all(); $data['user_id'] = user_id(); $data['user_type'] = user_type(); $data = $this->repository->create($data); $message = trans('messages.success.created', ['Module' => trans('search_log::search_log.name')]); $code = 204; $status = 'success'; $url = guard_url('search_log/search_log/' . $search_log->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('search_log/search_log'); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Update the search_log. * * @param Request $request * @param Model $search_log * * @return Response */ public function update(SearchLogRequest $request, SearchLog $search_log) { try { $data = $request->all(); $search_log->update($data); $message = trans('messages.success.updated', ['Module' => trans('search_log::search_log.name')]); $code = 204; $status = 'success'; $url = guard_url('search_log/search_log/' . $search_log->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('search_log/search_log/' . $search_log->getRouteKey()); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Remove the search_log. * * @param Model $search_log * * @return Response */ public function destroy(SearchLogRequest $request, SearchLog $search_log) { try { $search_log->delete(); $message = trans('messages.success.deleted', ['Module' => trans('search_log::search_log.name')]); $code = 202; $status = 'success'; $url = guard_url('search_log/search_log/0'); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('search_log/search_log/' . $search_log->getRouteKey()); } return compact('message', 'code', 'status', 'url'); } /** * Return the form elements as json. * * @param String $element * * @return json */ public function form($element = 'fields') { $form = new Form(); return $form->form($element, true); } }