via() public method
Specifies the relation associated with the junction table.
Use this method to specify a pivot record/table when declaring a relation in the yii\db\ActiveRecord class:
public function getOrders() { return $this->hasOne(Order::className(), ['id' => 'order_id']); } public function getOrderItems() { return $this->hasMany(Item::className(), ['id' => 'item_id']) ->via('orders'); }
public $this via ( $relationName, callable $callable = null ) | ||
---|---|---|
$relationName | string |
The relation name. This refers to a relation declared in $primaryModel. |
$callable | callable |
A PHP callback for customizing the relation associated with the junction table. Its signature should be |
return | $this |
The relation object itself. |
Please login to continue.