KeyPersonnel.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. namespace catchAdmin\yunying\model;
  3. use catcher\base\CatchModel as Model;
  4. use catchAdmin\permissions\model\DataRangScopeTrait;
  5. use catchAdmin\system\model\SysDictData;
  6. class KeyPersonnel extends Model
  7. {
  8. use DataRangScopeTrait;
  9. // 表名
  10. public $name = 'key_personnel';
  11. // 数据库字段映射
  12. public $field = array(
  13. 'id',
  14. // 姓名
  15. 'name',
  16. // 性别
  17. 'gender',
  18. // 证件类型
  19. 'card_type',
  20. // 证件号码
  21. 'card_number',
  22. // 地址
  23. 'address',
  24. // 监护人姓名
  25. 'guardians_name',
  26. // 监护人性别
  27. 'guardians_gender',
  28. // 监护人联系电话
  29. 'guardians_phone',
  30. // 监护人地址
  31. 'guardians_address',
  32. 'rfid_sn',
  33. // 创建人ID
  34. 'creator_id',
  35. // 创建时间
  36. 'created_at',
  37. // 更新时间
  38. 'updated_at',
  39. // 软删除
  40. 'deleted_at',
  41. );
  42. /**
  43. * 列表
  44. */
  45. public function getList()
  46. {
  47. $res=$this->dataRange()
  48. ->catchSearch()
  49. ->append(['guardians_gender_text', 'gender_text','card_type_text'])
  50. ->order($this->aliasField('id'), 'desc')
  51. ->paginate();
  52. return $res;
  53. }
  54. //根据姓名搜索
  55. public function searchNameAttr($query, $value, $data)
  56. {
  57. return $query->where('name', 'like', '%' . $value . '%');
  58. }
  59. public function searchRfidSnAttr($query, $value, $data)
  60. {
  61. return $query->where('name', 'like', '%' . $value . '%');
  62. }
  63. public function getGuardiansGenderTextAttr($value){
  64. $guardians_gender = $this->getData('guardians_gender');
  65. return (new SysDictData())->getValueByCode('GENDER_OPTION', $guardians_gender) ?: '';
  66. }
  67. public function getGenderTextAttr($value){
  68. $gender = $this->getData('gender');
  69. return (new SysDictData())->getValueByCode('GENDER_OPTION', $gender) ?: '';
  70. }
  71. public function getCardTypeTextAttr($value){
  72. $card_type = $this->getData('card_type');
  73. return (new SysDictData())->getValueByCode('CARD_TYPE_OPTION', $card_type) ?: '';
  74. }
  75. public function getGenderAttr($value){
  76. return (string)$value;
  77. }
  78. public function getGuardiansGenderAttr($value){
  79. return (string)$value;
  80. }
  81. }