MasterWorkerRegister.php 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 app\common\model\sale\Sale;
  18. use think\facade\Cache;
  19. /**
  20. * MasterWorkerRegister模型
  21. * Class MasterWorkerRegister
  22. * @package app\common\model\master_worker_register
  23. */
  24. class MasterWorkerRegister extends BaseModel
  25. {
  26. protected $name = 'master_worker_register';
  27. /*protected $type = [
  28. 'credential_images' => 'array',
  29. ];*/
  30. public function getCredentialImagesAttr($value)
  31. {
  32. return empty($value)?'':json_decode($value,true);
  33. }
  34. public function getCredentialNameAttr($value)
  35. {
  36. return empty($value)?[]:explode(',',$value);
  37. }
  38. public function getCityTextAttr($value,$data):string{
  39. $postageRegion = array_column(getPostageRegion([$data['city']]), null, 'id');
  40. return $postageRegion[$data['city']]['name']??'';
  41. }
  42. public function getMaintainExpTypeTextAttr($value,$data):string{
  43. $default = Cache::get('WORKER_EXP_TYPE');
  44. if (!$default) {
  45. $status = DictData::where('type_value', 'worker_exp_type')->column('name','value');
  46. Cache::set('WORKER_EXP_TYPE', json_encode($status,true),5);
  47. } else {
  48. $status = json_decode($default,true);
  49. }
  50. return $status[$data['maintain_exp_type']] ?? '';
  51. }
  52. public function getOtherExpTypeTextAttr($value,$data):string{
  53. $default = Cache::get('WORKER_OTHER_EXP_TYPE');
  54. if (!$default) {
  55. $status = DictData::where('type_value', 'worker_other_exp_type')->column('name','value');
  56. Cache::set('WORKER_OTHER_EXP_TYPE', json_encode($status,true),5);
  57. } else {
  58. $status = json_decode($default,true);
  59. }
  60. return $status[$data['other_exp_type']] ?? '';
  61. }
  62. public function getVehicleTypeTextAttr($value,$data):string{
  63. $default = Cache::get('WORKER_VEHICLE_TYPE');
  64. if (!$default) {
  65. $status = DictData::where('type_value', 'worker_vehicle_type')->column('name','value');
  66. Cache::set('WORKER_VEHICLE_TYPE', json_encode($status,true),5);
  67. } else {
  68. $status = json_decode($default,true);
  69. }
  70. return $status[$data['vehicle_type']] ?? '';
  71. }
  72. public function sale()
  73. {
  74. return $this->hasOne(Sale::class, 'id', 'sale_id');
  75. }
  76. }