/** * @param DoplioDbTable $item * * @return DoplioDbTable|null */ protected function sync(DoplioDbTable $item) { if ($item->getKey() && !$item->exists) { $with = []; foreach ($item->getRelations() as $withName => $withData) { $with[] = $withName; } $item = $item->with($with)->find($item->getKey()); } return $item; }