mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 07:12:47 +08:00
改进多对多关联的中间表模型提示
This commit is contained in:
@@ -68,12 +68,18 @@ class BelongsToMany extends Relation
|
|||||||
/**
|
/**
|
||||||
* 实例化中间表模型
|
* 实例化中间表模型
|
||||||
* @param $data
|
* @param $data
|
||||||
* @return mixed
|
* @return Pivot
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
protected function newPivot($data = [])
|
protected function newPivot($data = [])
|
||||||
{
|
{
|
||||||
$pivot = $this->pivotName ?: '\\think\\model\\Pivot';
|
$class = $this->pivotName ?: '\\think\\model\\Pivot';
|
||||||
return new $pivot($this->parent, $data, $this->middle);
|
$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