hasOne(Company::class, 'id', 'company_id')->bind(['company_name']); } public function company() { return $this->hasOne(Company::class, 'id', 'company_id'); } public function partyAInfo() { 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() { // halt($this->type); // if($this->type==1){ return $this->hasOne(Company::class, 'id', 'party_b')->field('id,company_name,organization_code,master_name,master_phone,master_email,area_manager'); // }else{ // return $this->hasOne(User::class, 'id', 'party_b')->field('id,nickname company_name'); // } } public function partyA() { return $this->hasOne(Company::class, 'id', 'party_a')->bind(['party_a_name' => 'company_name']); } public function partyB() { return $this->hasOne(Company::class, 'id', 'party_b')->bind(['party_b_name' => 'company_name']); } public function contractType() { return $this->hasOne(DictData::class, 'id', 'contract_type')->bind(['contract_type_name' => 'name']); } public function getContractTypeNameAttr($value) { return DictData::where(['id' => $this->contract_type])->value('name'); } }