service->sdk->FindById('Item', $id); } public function syncToNinja(array $records): void { $product_transformer = new ProductTransformer($this->service->company); foreach ($records as $record) { $ninja_data = $product_transformer->qbToNinja($record); if ($product = $this->findProduct($ninja_data['id'])) { $product->fill($ninja_data); $product->save(); } } } public function syncToForeign(array $records): void { } private function findProduct(string $key): ?Product { $search = Product::query() ->withTrashed() ->where('company_id', $this->service->company->id) ->where('sync->qb_id', $key); if($search->count() == 0) { $product = ProductFactory::create($this->service->company->id, $this->service->company->owner()->id); $sync = new ProductSync(); $sync->qb_id = $key; $product->sync = $sync; return $product; } elseif($search->count() == 1) { return $this->service->settings->product->update_record ? $search->first() : null; } return null; } }