Pivot.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkPHP [ WE CAN DO IT JUST THINK ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2006~2019 http://thinkphp.cn All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: liu21st <liu21st@gmail.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types = 1);
  12. namespace think\model;
  13. use think\Model;
  14. /**
  15. * 多对多中间表模型类
  16. */
  17. class Pivot extends Model
  18. {
  19. /**
  20. * 父模型
  21. * @var Model
  22. */
  23. public $parent;
  24. /**
  25. * 是否时间自动写入
  26. * @var bool
  27. */
  28. protected $autoWriteTimestamp = false;
  29. /**
  30. * 架构函数
  31. * @access public
  32. * @param array $data 数据
  33. * @param Model $parent 上级模型
  34. * @param string $table 中间数据表名
  35. */
  36. public function __construct(array $data = [], Model $parent = null, string $table = '')
  37. {
  38. $this->parent = $parent;
  39. if (is_null($this->name)) {
  40. $this->name = $table;
  41. }
  42. parent::__construct($data);
  43. }
  44. }