You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
you can use expand parameter, see this info in rest guide. However getting particular one info about related model is not supported now, so this issue can be open i think for further discussion @qiangxue ?
@jungyuyu well, it will have support once somone from core or other developers will have time for that ) you also can submit PR if ;) Lets keep this issue open for this feature discussion.
I need GET the user post list, request url as follow:
http://domain/restapi/users/1/posts
I add getPosts() in /models/User.php
public function getPosts()
{
return $this->hasMany(Post::className(), ['author_ID' => 'ID']);
}
But does not work, need modify urlManager? or extend some method()?
how to do it? guide me, please!
My tables as follow:
CREATE TABLE
yii2_user
(ID
bigint(20) unsigned NOT NULL AUTO_INCREMENT,...
)
CREATE TABLE
yii2_post
(ID
bigint(20) unsigned NOT NULL AUTO_INCREMENT,author_ID
bigint(20) unsigned NOT NULL DEFAULT '0',...
)
Best regards,
The text was updated successfully, but these errors were encountered: