hasOne('Customer', 'customer_id', 'customer_id')->bind([ 'customer_name' => 'name' ]); } /** * 关联合同模型 * * @return \think\model\relation\HasOne */ public function toContract() { return $this->hasOne('Contract', 'contract_id', 'contract_id')->bind([ 'contract_number' => 'num', 'contract_money' => 'money' ]); } /** * 关联用户模型 * * @return \think\model\relation\HasOne */ public function toAdminUser() { return $this->hasOne('AdminUser', 'id', 'owner_user_id')->bind([ 'owner_user_name' => 'realname' ]); } }