改进Pivot类

This commit is contained in:
thinkphp
2017-03-23 17:42:29 +08:00
parent f1da00a2a3
commit 0ee05eb1ca

View File

@@ -19,25 +19,26 @@ class Pivot extends Model
/** @var Model */
public $parent;
protected $autoWriteTimestamp = false;
/**
* 构函数
* 构函数
* @access public
* @param Model $parent
* @param array|object $data 数据
* @param string $table 中间数据表名
* @param Model $parent 上级模型
* @param array|object $data 数据
* @param string $table 中间数据表名
*/
public function __construct(Model $parent, $data = [], $table = '')
{
if (is_object($data)) {
$this->data = get_object_vars($data);
} else {
$this->data = $data;
}
$this->parent = $parent;
if (is_null($this->name)) {
$this->name = $table;
}
parent::__construct($data);
$this->class = $this->name;
}
}