所以,这是我的控制器:
$topics = Topic::where('board_id', $id)->with('user')->get();
$topic = Topic::find($id);
$board = Boards::where('id', $id)->get();
return view('boards.show')->with('topics', $topics)->with('topic', $topic)->with('board', $board);
以下是生成URL的代码:
@foreach($board as $boards)
No Posts Found
@endforeach
但是,如果我正在删除foreach循环,它会给出错误:
Property [id] does not exist on this collection instance.
但是为什么呢,我必须循环,如果它只从板表中获得一行?没有为每个循环运行的任何解决方案???