Repo.php 859 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace app\common\model;
  3. class Repo extends Base
  4. {
  5. protected $schema = [
  6. 'id' => 'int', // id
  7. 'name' => 'varchar', // 仓库名称
  8. 'desc' => 'varchar', // 仓库说明
  9. 'address' => 'varchar', // 仓库地址
  10. 'create_time' => 'datetime', // 创建时间
  11. 'update_time' => 'datetime', // 更新时间
  12. 'delete_time' => 'datetime', // 删除时间
  13. 'valid' => 'tinyint', // 状态,1启用,0禁用
  14. 'parent' => 'int', // 父仓库id
  15. ];
  16. public function logs()
  17. {
  18. return $this->hasMany(Repo::class);
  19. }
  20. public function parent()
  21. {
  22. return $this->belongsTo(Repo::class, 'id', 'parent');
  23. }
  24. public function children()
  25. {
  26. return $this->hasMany(Repo::class, 'parent', 'id');
  27. }
  28. }