예제 #1
0
 /**
  * @param \Notadd\Foundation\Database\Eloquent\Model|int $model
  * @return \Notadd\Foundation\Database\Eloquent\Model
  */
 public function associate($model)
 {
     $otherKey = $model instanceof Model ? $model->getAttribute($this->otherKey) : $model;
     $this->parent->setAttribute($this->foreignKey, $otherKey);
     if ($model instanceof Model) {
         $this->parent->setRelation($this->relation, $model);
     }
     return $this->parent;
 }