123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- namespace app\common\model;
- use app\common\constant\CommonConstant;
- use think\Model;
- /**
- * 出差申请模型
- */
- class EvectionInfo extends Model
- {
- // 表名
- protected $name = 'evection_info';
- // 追加属性
- protected $append = [
- 'document_text',
- 'images_text',
- ];
- public function getDocumentTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['document']) ? $data['document'] : '');
- return $value ? explode(',', $value) : [];
- }
- public function getImagesTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['images']) ? $data['images'] : '');
- return $value ? explode(',', $value) : [];
- }
- // 关联出差同行人员
- public function peerUser()
- {
- return $this->hasMany(EvectionPeerUser::class, 'info_id', 'id');
- }
- // 关联出差审批
- public function approve()
- {
- return $this->hasMany(EvectionApprove::class, 'info_id', 'id')->where('is_deleted',CommonConstant::IS_DELETED_0);
- }
- // 关联出差审批
- public function approveInfo()
- {
- return $this->hasOne(EvectionApprove::class, 'info_id', 'id')->where('is_deleted',CommonConstant::IS_DELETED_0)->where('approve_type', CommonConstant::TYPE_1);
- }
- }
|