/** * Associate the given model. * * @param Record $instance * @return bool */ public function associate(Record $instance) { $instance->save(); $this->set(array($instance)); $this->parent->set($this->foreignKey, $instance->id()); return $this->parent->save(); }
/** * Save the given record to storage if it hasn't got an ID. * * @param Record $instance */ protected function persist(Record $instance) { if (!$instance->id()) { $instance->save(); } }