Question about relations and magic getters

I have a model (Offer) which has a relation getContactPeople().

When I access the relation…

$offer = Offer::find($offerId);

the output from the (magic getter) property is an array, while the method is still an ActiveQuery. I expected them to be equal.

Is there something in the docs about the rationale behind this behavior?

Additional question: How could I order contact people by a rank in the ContactPeople model?


not sure what you mean with that? Something like this?

var_dump($offer->getContactPeople()->orderBy(['rank' => SORT_ASC])->all());
1 Like