bug in with() and relation query

not sure if it’s a bug but or just me so I’m posting it here first

item has a many_many relationship with order

item belongs_to lead

$order->items(array(‘with’=>‘lead’)) //works

$order->with(‘items’)->items //does not work

The latter throws an error: Relation "item" is not defined in active record class "Order".

I don’t understand. Are you trying to access items data? Then why not do:

foreach ($order->items as $item) {


Yes, but I want the leads to be eagerly loaded. As stated in the topic, an item has_many leads