public function model(AbstractModel $model) { $data = $model->getChanges(); $model->getRepo()->getSerializers()->serialize($data); $this->set($data)->where($model->getRepo()->getPrimaryKey(), $model->getId()); return $this; }
/** * @param AbstractModel $model * @param AbstractModel $foreign */ public function updateInverse(AbstractModel $model, AbstractModel $foreign) { $link = $foreign->getLinkOne($this->getName()); if ($link->get() !== $model) { $link->set($model); } }
/** * @param AbstractModel $model * @param AbstractModel $foreign * @return boolean */ public function areLinked(AbstractModel $model, AbstractModel $foreign) { return $model->getId() == $foreign->{$this->getThroughKey()}; }
/** * @return LinkOne $this */ public function clear() { $this->current->setStateVoid(); return $this; }