MedicalDept.php 832 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace app\model;
  3. use support\Model;
  4. class MedicalDept extends Model
  5. {
  6. protected $table = 'medical_dept';
  7. protected $primaryKey = 'dept_id';
  8. protected $dateFormat = 'U';
  9. public const CREATED_AT = 'dept_addTime';
  10. public const UPDATED_AT = 'dept_updateTime';
  11. /**
  12. * @Desc 根据主键获取数据
  13. * @Author Gorden
  14. * @Date 2024/3/1 15:59
  15. *
  16. * @param $id
  17. * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model|object|null
  18. */
  19. public function getByPrimaryKey($id)
  20. {
  21. return self::where('dept_id', $id)->first();
  22. }
  23. /**
  24. * 根据path获取指定科室的所有下级
  25. */
  26. public function getAllSubDept($path)
  27. {
  28. return self::where('dept_path', 'like', $path . '%')->get()->toArray();
  29. }
  30. }