public function update(LinkOne $link) { if ($link->isChanged()) { $link->get()->{$this->getForeignKey()} = $link->getModel()->{$this->getKey()}; $link->getOriginal()->{$this->getForeignKey()} = null; } }
/** * @covers ::clear */ public function testClear() { $model = new Country(); $link = new LinkOne(new City(), City::getRepo()->getRel('country'), $model); $link->clear(); $this->assertTrue($link->get()->isVoid()); }
public function update(LinkOne $link) { $link->getModel()->{$this->key} = $link->get()->getId(); $link->getModel()->{$this->classKey} = get_class($link->get()); }
/** * @param LinkOne $link */ public function update(LinkOne $link) { $link->getModel()->{$this->getKey()} = $link->get()->getId(); }