Closed ghost closed 7 years ago
我在Blade模板使用{{ $topic->countVoters() }}输出$topic的总vote数,但为什么它会去数据表里面找topic_id?我代码里面没写这个,自然也不可能找到。
{{ $topic->countVoters() }}
topic_id
@iVanilla 请问你在 Topic 模型里面有没有添加这一行 protected $vote = User::class; ? 你尝试加一下,我后面版本会去掉这参数。
Topic
protected $vote = User::class;
@jcc 好了,已解决。
我在Blade模板使用
{{ $topic->countVoters() }}
输出$topic的总vote数,但为什么它会去数据表里面找topic_id
?我代码里面没写这个,自然也不可能找到。