public function searchProduct($domain, $searchString, Request $request) { $productService = new productService(); $trackingService = new trackingService(); $result['ok'] = 0; $userId = \Kacana\Util::isLoggedIn() ? $this->_user->id : 0; $page = $request->input('page', 1); $limit = $request->input('limit', KACANA_PRODUCT_ITEM_PER_TAG); $sort = $request->input('sort'); $options = ['sort' => $sort]; $products = $productService->searchProduct($searchString, $limit, $page, $options, $userId); $trackingService->createTrackingSearch($searchString, $userId, $request->ip(), 'sub'); $result['ok'] = 1; $result['products'] = $products; $result['search'] = $searchString; return view('client.index.search', $result); }
public function suggestSearchProduct(Request $request) { $productService = new productService(); $trackingService = new trackingService(); $result['ok'] = 0; $userId = \Kacana\Util::isLoggedIn() ? $this->_user->id : 0; try { $searchString = $request->input('search', false); $data = $productService->suggestSearchProduct($searchString); $trackingService->createTrackingSearch($searchString, $userId, $request->ip()); if ($data) { $result['data'] = $data; $result['ok'] = 1; } } catch (\Exception $e) { if ($request->ajax()) { $result['error'] = $e->getMessage(); return $result; } else { return view('errors.404', ['error_message' => $e]); } } return response()->json($result); }
public function reportDetailTableTrackingSearch(Request $request) { $params = $request->all(); $trackingService = new trackingService(); try { $return = $trackingService->reportDetailTableTrackingSearch($params); } catch (\Exception $e) { // @codeCoverageIgnoreStart $return['error'] = $e->getMessage(); $return['errorMsg'] = $e->getMessage(); // @codeCoverageIgnoreEnd } return response()->json($return); }