MedicalDept.php 935 B

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