だから、ここに私のコントローラである:LaravelでWHEREを使用した後にデータを取得するループがあるのはなぜですか?
@foreach($board as $boards)
<a href="/topics/create/{{$boards->id}}">Create New Post</a>
<p>No Posts Found</p>
@endforeach
しかし、私は、foreachループを削除していた場合、それはエラーを与えている:
Property [id] does not exist on this collection instance.
$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のを生成するためのコードです
しかし、なぜボードテーブルから1行しか得られないのですか?各ループのために実行することなくそれを行う任意のソリューション???
はい、ではありません。再度、感謝します。 –
代わりにfirst()またはtake(1) –