Hi there,
I have kind of a problem.
In some cases, I opt to avoid lazy loading. In those cases I just use the query builder to directly join those.
So my question is: How can I access the joined models ?
Image that we are in the robot model. this model has:
$this->hasMany("id", "Models\Item", "robotId", array('alias' => 'items'));
and my item model has
$this->hasOne("itemId", "Models\RawItem", "id", array('alias' => 'rawItem'));
So in my robot model I just write a function:
public function getItemsEquipped() {
return $this->modelsManager->createBuilder()
->from('Models\Item')
->join('Models\RawItem')
->where('isEquipped = 1')
->andWhere('robotId = :rid:')
->getQuery()
->execute(array('rid' => $this->id));
}
Everything works fine so far BUT how can I access the joined RawItem ?
If I try to use $itemsReturned[0]->rawItem, it executes the hasOne relation and queries the table once again.
Hope my description makes sense and that somebody has an awnser to that :)
Greetings