public function saveAll() { if ($this->data instanceof Collection) { foreach ($this->data as $item) { if ($item instanceof DataModel) { $item->save(); } } } }
/** * Saves all related items. For many-to-many relations there are two things we have to do: * 1. Save all related items; and * 2. Overwrite the pivot table data with the new associations */ public function saveAll() { // Save all related items parent::saveAll(); $this->saveRelations(); }