Laravel 下 如何进行模型关联 从而获取文章评论 id
为了能够对文章的评论进行点赞投票,尝试编写如下代码,保存之后 ,laravel报错:Missing argument
请问如何解决
//获取comment_id
public function vote(Novel $novel )
{$param=[
'user_id'=>\Auth::id(),
'comment_id'=>$post->comment()->id,
];
//模型关联
public function comment($id)
{
return $this->hasOne ('App\Comment' )->where ('post_id',$id);
}
推荐文章: