| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <?php
- // +----------------------------------------------------------------------
- // | likeadmin快速开发前后端分离管理后台(PHP版)
- // +----------------------------------------------------------------------
- // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
- // | 开源版本可自由商用,可去除界面版权logo
- // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
- // | github下载:https://github.com/likeshop-github/likeadmin
- // | 访问官网:https://www.likeadmin.cn
- // | likeadmin团队 版权所有 拥有最终解释权
- // +----------------------------------------------------------------------
- // | author: likeadminTeam
- // +----------------------------------------------------------------------
- namespace app\common\model\master_worker_register;
- use app\common\model\BaseModel;
- use app\common\model\dict\DictData;
- use app\common\model\sale\Sale;
- use think\facade\Cache;
- /**
- * MasterWorkerRegister模型
- * Class MasterWorkerRegister
- * @package app\common\model\master_worker_register
- */
- class MasterWorkerRegister extends BaseModel
- {
-
- protected $name = 'master_worker_register';
- /*protected $type = [
- 'credential_images' => 'array',
- ];*/
- public function getCredentialImagesAttr($value)
- {
- return empty($value)?'':json_decode($value,true);
- }
- public function getCredentialNameAttr($value)
- {
- return empty($value)?[]:explode(',',$value);
- }
- public function getCityTextAttr($value,$data):string{
- $postageRegion = array_column(getPostageRegion([$data['city']]), null, 'id');
- return $postageRegion[$data['city']]['name']??'';
- }
- public function getMaintainExpTypeTextAttr($value,$data):string{
- $default = Cache::get('WORKER_EXP_TYPE');
- if (!$default) {
- $status = DictData::where('type_value', 'worker_exp_type')->column('name','value');
- Cache::set('WORKER_EXP_TYPE', json_encode($status,true),5);
- } else {
- $status = json_decode($default,true);
- }
- return $status[$data['maintain_exp_type']] ?? '';
- }
- public function getOtherExpTypeTextAttr($value,$data):string{
- $default = Cache::get('WORKER_OTHER_EXP_TYPE');
- if (!$default) {
- $status = DictData::where('type_value', 'worker_other_exp_type')->column('name','value');
- Cache::set('WORKER_OTHER_EXP_TYPE', json_encode($status,true),5);
- } else {
- $status = json_decode($default,true);
- }
- return $status[$data['other_exp_type']] ?? '';
- }
- public function getVehicleTypeTextAttr($value,$data):string{
- $default = Cache::get('WORKER_VEHICLE_TYPE');
- if (!$default) {
- $status = DictData::where('type_value', 'worker_vehicle_type')->column('name','value');
- Cache::set('WORKER_VEHICLE_TYPE', json_encode($status,true),5);
- } else {
- $status = json_decode($default,true);
- }
- return $status[$data['vehicle_type']] ?? '';
- }
- public function sale()
- {
- return $this->hasOne(Sale::class, 'id', 'sale_id');
- }
- }
|