mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
改进多对多关联的中间表模型提示
This commit is contained in:
@@ -68,12 +68,18 @@ class BelongsToMany extends Relation
|
||||
/**
|
||||
* 实例化中间表模型
|
||||
* @param $data
|
||||
* @return mixed
|
||||
* @return Pivot
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function newPivot($data = [])
|
||||
{
|
||||
$pivot = $this->pivotName ?: '\\think\\model\\Pivot';
|
||||
return new $pivot($this->parent, $data, $this->middle);
|
||||
$class = $this->pivotName ?: '\\think\\model\\Pivot';
|
||||
$pivot = new $class($this->parent, $data, $this->middle);
|
||||
if ($pivot instanceof Pivot) {
|
||||
return $pivot;
|
||||
} else {
|
||||
throw new Exception('pivot model must extends: \think\model\Pivot');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user