예제 #1
0
 /**
  * @param  LinkOne       $link
  */
 public function update(LinkOne $link)
 {
     parent::update($link);
     if ($link->isChanged()) {
         $path = $link->get()->getChildrenPath();
         return $link->getModel()->setPathAndUpdateDescendants($path);
     }
 }
예제 #2
0
 /**
  * @covers ::update
  */
 public function testUpdate()
 {
     $rel = new BelongsTo('country', City::getRepo()->getConfig(), 'Harp\\Harp\\Test\\TestModel\\Country');
     $model = new City(['countryId' => 2]);
     $foreign = new Country(['id' => 20]);
     $link = new LinkOne($model, $rel, $foreign);
     $rel->update($link);
     $this->assertEquals(20, $model->countryId);
 }