Inheritance: extends BaseRepository
 /**
  * @param $accountId
  * @return \Illuminate\Http\JsonResponse
  */
 public function getDatatable($accountId, $search)
 {
     $datatable = new ProductDatatable(true);
     $query = $this->productRepo->find($accountId, $search);
     if (!Utils::hasPermission('view_all')) {
         $query->where('products.user_id', '=', Auth::user()->id);
     }
     return $this->datatableService->createDatatable($datatable, $query);
 }
 /**
  * @param UpdateProductRequest $request
  * @param $publicId
  * @return \Illuminate\Http\Response
  */
 public function update(UpdateProductRequest $request, $publicId)
 {
     if ($request->action) {
         return $this->handleAction($request);
     }
     $data = $request->input();
     $data['public_id'] = $publicId;
     $product = $this->productRepo->save($data, $request->entity());
     return $this->itemResponse($product);
 }
 private function initMaps()
 {
     $this->init();
     $this->maps = ['client' => [], 'invoice' => [], 'invoice_client' => [], 'product' => [], 'countries' => [], 'countries2' => [], 'currencies' => [], 'client_ids' => [], 'invoice_ids' => [], 'vendors' => [], 'expense_categories' => []];
     $clients = $this->clientRepo->all();
     foreach ($clients as $client) {
         $this->addClientToMaps($client);
     }
     $invoices = $this->invoiceRepo->all();
     foreach ($invoices as $invoice) {
         $this->addInvoiceToMaps($invoice);
     }
     $products = $this->productRepo->all();
     foreach ($products as $product) {
         $this->addProductToMaps($product);
     }
     $countries = Cache::get('countries');
     foreach ($countries as $country) {
         $this->maps['countries'][strtolower($country->name)] = $country->id;
         $this->maps['countries2'][strtolower($country->iso_3166_2)] = $country->id;
     }
     $currencies = Cache::get('currencies');
     foreach ($currencies as $currency) {
         $this->maps['currencies'][strtolower($currency->code)] = $currency->id;
     }
     $vendors = $this->vendorRepo->all();
     foreach ($vendors as $vendor) {
         $this->addVendorToMaps($vendor);
     }
     $expenseCaegories = $this->expenseCategoryRepo->all();
     foreach ($expenseCaegories as $category) {
         $this->addExpenseCategoryToMaps($category);
     }
 }
 /**
  * @param $accountId
  * @return \Illuminate\Http\JsonResponse
  */
 public function getDatatable($accountId)
 {
     $datatable = new ProductDatatable(false);
     $query = $this->productRepo->find($accountId);
     return $this->datatableService->createDatatable($datatable, $query);
 }