请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

Call to a member function pluck() on null

老师,个人中心页面中:

// 获取关注用户及他们的关注、粉丝、文章数

$stars = $user->starts;

$susers = User::whereIn('id', $stars->pluck('star_id'))->withCount(['stars', 'fans', 'posts'])->get();

// 获取粉丝用户及他们的关注、粉丝、文章数

$fans = $user->fans;

$fusers = User::whereIn('id', $fans->pluck('fan_id'))->withCount(['stars', 'fans', 'posts'])->get();

报: Call to a member function pluck() on null 错:

https://img1.sycdn.imooc.com/szimg//594f7a8c00010c5e10480309.jpg

Fan模型代码:

https://img1.sycdn.imooc.com/szimg//594f7aa5000138ed05570445.jpg

Post模型代码:

https://img1.sycdn.imooc.com/szimg//594f7abc0001276406711081.jpg

User模型代码:

https://img1.sycdn.imooc.com/szimg//594f7aea0001a90106081006.jpg

User控制器:

https://img1.sycdn.imooc.com/szimg//594f7b1a0001df3e09610589.jpg

正在回答

1回答

轩脉刃 2017-06-29 07:34:05

$user->starts  应该是 $user->stars

0 回复 有任何疑惑可以回复我~
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信