我正在尝试在我的小型博客应用程序中访问用户对象关系。
它已经在我在视图中的数组中 - 我只是不知道如何实际访问它。
$blog->user->username 不起作用。
如何访问用户名?
这是数组:
Blog Object
(
[includes] => Array
(
[0] => User
)
[attributes] => Array
(
[id] => 1
[title] => Gryderet
[text] => Ja øv, så skal vi have gryderet igen
[user_id] => 1
[created_at] => 0000-00-00 00:00:00
[updated_at] => 0000-00-00 00:00:00
)
[original] => Array
(
[id] => 1
[title] => Gryderet
[text] => Ja øv, så skal vi have gryderet igen
[user_id] => 1
[created_at] => 0000-00-00 00:00:00
[updated_at] => 0000-00-00 00:00:00
)
[relationships] => Array
(
[User] => User Object
(
[attributes] => Array
(
[id] => 1
[username] => Patrick
[password] => hej123
[created_at] => 0000-00-00
[updated_at] => 0000-00-00
)
[original] => Array
(
[id] => 1
[username] => Patrick
[password] => hej123
[created_at] => 0000-00-00
[updated_at] => 0000-00-00
)
[relationships] => Array
(
)
[exists] => 1
[includes] => Array
(
)
)
)
[exists] => 1
)