hasOne(Company::class, 'id', 'company_id')->bind(['company_name']); } public function company(): \think\model\relation\HasOne { return $this->hasOne(Company::class, 'id', 'company_id'); } public function partyAInfo(): \think\model\relation\HasOne { return $this->hasOne(Company::class, 'id', 'party_a')->field('id,company_name,organization_code,master_name,master_phone,master_email,area_manager'); } public function partyBInfo(): \think\model\relation\HasOne { return $this->hasOne(Company::class, 'id', 'party_b')->field('id,company_name,organization_code,master_name,master_phone,master_email,area_manager'); } public function partyA(): \think\model\relation\HasOne { return $this->hasOne(Company::class, 'id', 'party_a')->bind(['party_a_name' => 'company_name']); } public function partyB(): \think\model\relation\HasOne { return $this->hasOne(Company::class, 'id', 'party_b')->bind(['party_b_name' => 'company_name']); } public function contractType(): \think\model\relation\HasOne { return $this->hasOne(WorkerDictData::class, 'id', 'contract_type')->bind(['contract_type_name' => 'name']); } public function getContractTypeNameAttr($value) { return WorkerDictData::where(['id' => $this->contract_type])->value('name'); } }