关系viaTable yii2

时间:2016-12-23 07:12:54

标签: yii2

我有3个表格(orderorder_deliveryorder_types)。每张桌子都有模特。对于订单我创建GridView。表格order包含列order_number,表order_delivery包含order_numberorder_delivery_code,表格order_type包含delivery_types_codedelivery_types_name }。按顺序我写函数

public function getType() {
    return $this->hasOne(OrderDelivery::className(), ['order_id' => 'order_id']) 
        ->viaTable('delivery-types', ['delivery-types_code' => 'order_delivery_code']); 
}

index我写type.delivery-types_name - 有

  

获取未知属性:backend \ models \ Order :: order_delivery_code

我做错了什么?

UPD。我的错)

public function getType(){
    return $this->hasOne(DeliveryTypes::className(), ['delivery-types_code' => 'order_delivery_code'])
        ->viaTable('order_delivery', ['order_id' => 'order_id']);
}

0 个答案:

没有答案