update(['tax_per_item' => true]); foreach ($taxes as $tax) { $item->taxes()->create([ ...$tax, 'company_id' => $companyId, ]); } } public function replace(Item $item, array $taxes, int $companyId): void { $item->taxes()->delete(); $this->attach($item, $taxes, $companyId); } }