datatableService = $datatableService; $this->productRepo = $productRepo; } /** * @return ProductRepository */ protected function getRepo() { return $this->productRepo; } /** * @param $accountId * @param mixed $search * * @return \Illuminate\Http\JsonResponse */ public function getDatatable($accountId, $search) { $datatable = new ProductDatatable(true); $query = $this->productRepo->find($accountId, $search); if (! Utils::hasPermission('view_product')) { $query->where('products.user_id', '=', Auth::user()->id); } return $this->datatableService->createDatatable($datatable, $query); } }