【发布时间】:2020-07-08 12:47:56
【问题描述】:
我正在我的 Laravel 项目中创建一个评论表,以便用户可以评论产品。我想在 Laravel 中制作一个可以与我的用户表(例如一对多关系)集成的表。
这是我的代码:
public function buyproduct($id){
$user = Auth::user();
$users_comment = User::with('comments')->get();
$comments =comments::orderBy('id','desc')->get();
$renimage = Clothes::where('id',$id)->first();
return view('pages.products',[
'renimage'=>$renimage,
'google_avater'=>$user,
'comments'=>$users_comment
]);
}
在这里,我将数据发送到项目中的视图。我不明白如何访问我的用户表中的数据以及评论表中的数据。
【问题讨论】: