HospitalLevel.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace app\model;
  3. use think\Model;
  4. class HospitalLevel extends Model
  5. {
  6. protected $connection = 'mysql';
  7. protected $pk = 'id';
  8. protected $name = 'hospital_level';
  9. public static function getTitle($id = '')
  10. {
  11. $data = self::where(['id' => $id])->find();
  12. if (!empty($data)) {
  13. $data = $data->toArray();
  14. }
  15. return $data['title'];
  16. }
  17. public static function getpcarray()
  18. {
  19. $data = self::field('id,title')->where(['weid' => weid()])->select()->toArray();
  20. $datalist = [];
  21. foreach ($data as $key => $vo) {
  22. $datalist[$key]['val'] = $vo['id'];
  23. $datalist[$key]['key'] = $vo['title'];
  24. }
  25. return $datalist;
  26. }
  27. public static function getarray()
  28. {
  29. $data = self::where(['weid' => weid()])->order('id asc')->select()->toArray();
  30. if (!empty($data))
  31. foreach ($data as $vo) {
  32. $datalist[$vo['id']] = $vo['title'];
  33. }
  34. else
  35. $datalist['0'] = '可添加医院等级选择';
  36. return $datalist;
  37. }
  38. public static function datainitial()
  39. {
  40. $weid = weid();
  41. $datalist = self::where(['weid' => $weid])->select()->toArray();
  42. if (empty($datalist)) {
  43. self::create([
  44. 'weid' => $weid,
  45. 'title' => '三甲医院',
  46. 'status' => 1
  47. ]);
  48. }
  49. }
  50. }