2023-11-04 16:28:09 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace app\common\model\contract;
|
|
|
|
|
|
|
|
use app\common\model\BaseModel;
|
2023-11-06 16:19:20 +08:00
|
|
|
use app\common\model\company\Company;
|
|
|
|
use app\common\model\dict\WorkerDictData;
|
2023-11-04 16:28:09 +08:00
|
|
|
|
|
|
|
class Contract extends BaseModel
|
|
|
|
{
|
|
|
|
protected $connection = 'mysql2';
|
|
|
|
protected $name = 'la_contract';
|
2023-11-06 16:19:20 +08:00
|
|
|
|
|
|
|
public function companyName(): \think\model\relation\HasOne
|
|
|
|
{
|
|
|
|
return $this->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');
|
|
|
|
}
|
2023-11-04 16:28:09 +08:00
|
|
|
}
|