SysDept.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace app\model;
  3. use support\Model;
  4. class SysDept extends Model
  5. {
  6. // 关联表
  7. protected $table = 'sys_dept';
  8. protected $primaryKey = 'dept_id';
  9. protected $dateFormat = 'U';
  10. const CREATED_AT = 'dept_addtimes';
  11. const UPDATED_AT = null;
  12. /**
  13. * @Desc 获取子部门
  14. * @Author Gorden
  15. * @Date 2024/3/7 14:03
  16. *
  17. * @param $path
  18. * @return array
  19. */
  20. public static function getAllSubDept($path)
  21. {
  22. return self::where('dept_super_path', 'like', $path . '%')->get()->toArray();
  23. }
  24. /**
  25. * @Desc 验证指定字段指定值是否存在
  26. * @Author Gorden
  27. * @Date 2024/3/22 14:52
  28. *
  29. * @param $category
  30. * @param $field
  31. * @param $value
  32. * @return bool
  33. */
  34. public static function checkExist($category, $field, $value)
  35. {
  36. return self::where('dept_category', $category)
  37. ->where($field, $value)
  38. ->exists();
  39. }
  40. public function premises(){
  41. return $this->hasOne(self::class,'dept_id','dept_super_id');
  42. }
  43. }