MedicalDept.php 936 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. const CREATED_AT = 'dept_addTime';
  10. const UPDATED_AT = 'dept_updateTime';
  11. public function serializeDate(\DateTimeInterface $date)
  12. {
  13. return $date->format('Y-m-d H:i:s');
  14. }
  15. /**
  16. * @Desc 根据主键获取数据
  17. * @Author Gorden
  18. * @Date 2024/3/1 15:59
  19. *
  20. * @param $id
  21. * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model|object|null
  22. */
  23. public function getByPrimaryKey($id)
  24. {
  25. return self::where('dept_id', $id)->first();
  26. }
  27. /**
  28. * 根据path获取指定科室的所有下级
  29. */
  30. public function getAllSubDept($path)
  31. {
  32. return self::where('dept_path', 'like', $path . '%')->get()->toArray();
  33. }
  34. }