Skip to content

Commit

Permalink
修复关联对象动态设置表后缀之后写入数据时不自动添加数据表后缀的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
axguowen authored and liu21st committed Jun 25, 2024
1 parent 88629ec commit c318855
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/model/relation/HasMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ public function make(array|Model $data = []): Model
// 保存关联表数据
$data[$this->foreignKey] = $this->parent->{$this->localKey};

return new $this->model($data);
return (new $this->model($data))->setSuffix($this->getModel()->getSuffix());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/model/relation/MorphMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ public function make($data = []): Model
$data[$this->morphKey] = $this->parent->$pk;
$data[$this->morphType] = $this->type;

return new $this->model($data);
return (new $this->model($data))->setSuffix($this->getModel()->getSuffix());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/model/relation/MorphOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ public function make(array|Model $data = []): Model
$data[$this->morphKey] = $this->parent->$pk;
$data[$this->morphType] = $this->type;

return new $this->model($data);
return (new $this->model($data))->setSuffix($this->getModel()->getSuffix());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/model/relation/OneToOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public function make(array|Model $data = []): Model
// 保存关联表数据
$data[$this->foreignKey] = $this->parent->{$this->localKey};

return new $this->model($data);
return (new $this->model($data))->setSuffix($this->getModel()->getSuffix());
}

/**
Expand Down

0 comments on commit c318855

Please sign in to comment.