framework/db/ActiveRelationTrait.php
public function via($relationName, callable $callable = null)
    {
        $relation = $this->primaryModel->getRelation($relationName);
        $callableUsed = $callable !== null;
        $this->via = [$relationName, $relation, $callableUsed];
        if ($callable !== null) {
            call_user_func($callable, $relation);
        }

        return $this;
    }
public function via($relationName, callable $callable = null)
    {
        $relation = $this->primaryModel->getRelation($relationName);
        $callableUsed = $callable !== null;
        $this->via = [$relationName, $relation, $callableUsed];
        if ($callable !== null) {
            call_user_func($callable, $relation);
        }

        return $this;
    }
public function via ( $ relationName , callable $ callable = null ) { $ relation = $ this -> primaryModel -> getRelation ( $ relationName ) ; $ callableUsed = $ callable !== null ; $ this -> via = [ $ relationName , $ relation , $ callableUsed ] ; if ( $ callable !== null ) { call_user_func ( $ callable , $ relation ) ; } return $ this ; }
Specifies the relation associated with the junction table.

Use this method to specify a pivot record/table when declaring a relation in the [[ActiveRecord]] class:

```php
class Order extends ActiveRecord
{
public function getOrderItems() {
return $this->hasMany(OrderItem::className(), ['order_id' => 'id']);
}

public function getItems() {
return $this->hasMany(Item::className(), ['id' => 'item_id'])
->via('orderItems');
}
}
```

@param string $relationName the relation name. This refers to a relation declared in [[primaryModel]].
@param callable $callable a PHP callback for customizing the relation associated with the junction table.
Its signature should be `function($query)`, where `$query` is the query to be customized.
@return $this the relation object itself.
Specifies the relation associated with the junction table .