MasterWorkerRegister.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeadmin快速开发前后端分离管理后台(PHP版)
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
  8. // | github下载:https://github.com/likeshop-github/likeadmin
  9. // | 访问官网:https://www.likeadmin.cn
  10. // | likeadmin团队 版权所有 拥有最终解释权
  11. // +----------------------------------------------------------------------
  12. // | author: likeadminTeam
  13. // +----------------------------------------------------------------------
  14. namespace app\common\model\master_worker_register;
  15. use app\common\model\BaseModel;
  16. use app\common\model\dict\DictData;
  17. use think\facade\Cache;
  18. /**
  19. * MasterWorkerRegister模型
  20. * Class MasterWorkerRegister
  21. * @package app\common\model\master_worker_register
  22. */
  23. class MasterWorkerRegister extends BaseModel
  24. {
  25. protected $name = 'master_worker_register';
  26. /*protected $type = [
  27. 'credential_images' => 'array',
  28. ];*/
  29. public function getCredentialImagesAttr($value)
  30. {
  31. return empty($value)?'':json_decode($value,true);
  32. }
  33. public function getCredentialNameAttr($value)
  34. {
  35. return empty($value)?[]:explode(',',$value);
  36. }
  37. public function getCityTextAttr($value,$data):string{
  38. $postageRegion = array_column(getPostageRegion([$data['city']]), null, 'id');
  39. return $postageRegion[$data['city']]['name']??'';
  40. }
  41. public function getMaintainExpTypeTextAttr($value,$data):string{
  42. $default = Cache::get('WORKER_EXP_TYPE');
  43. if (!$default) {
  44. $status = DictData::where('type_value', 'worker_exp_type')->column('name','value');
  45. Cache::set('WORKER_EXP_TYPE', json_encode($status,true),5);
  46. } else {
  47. $status = json_decode($default,true);
  48. }
  49. return $status[$data['maintain_exp_type']] ?? '';
  50. }
  51. public function getOtherExpTypeTextAttr($value,$data):string{
  52. $default = Cache::get('WORKER_OTHER_EXP_TYPE');
  53. if (!$default) {
  54. $status = DictData::where('type_value', 'worker_other_exp_type')->column('name','value');
  55. Cache::set('WORKER_OTHER_EXP_TYPE', json_encode($status,true),5);
  56. } else {
  57. $status = json_decode($default,true);
  58. }
  59. return $status[$data['other_exp_type']] ?? '';
  60. }
  61. public function getVehicleTypeTextAttr($value,$data):string{
  62. $default = Cache::get('WORKER_VEHICLE_TYPE');
  63. if (!$default) {
  64. $status = DictData::where('type_value', 'worker_vehicle_type')->column('name','value');
  65. Cache::set('WORKER_VEHICLE_TYPE', json_encode($status,true),5);
  66. } else {
  67. $status = json_decode($default,true);
  68. }
  69. return $status[$data['vehicle_type']] ?? '';
  70. }
  71. }