I'm not sure how the second part of this example is related to the first, and where it belongs. I am quoting from page 174 of YiiBook2:
# models/Page.php
public function getUser() {
return $this->hasOne(User::className(), ['id' => 'user_id']);
}
This means you can fetch every page with every page author in one step:
$pages = Page::find()->with('user')->all();
I'm guessing that
with('user')
calls the getUser method.
Is that right?
But in which file does the second part of the example belong? In the view file?