So, here is my controller:
$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);
And here is the code for generating URL's:
@foreach($board as $boards)
<a href="/topics/create/">Create New Post</a>
<p>No Posts Found</p>
@endforeach
But if i'm removing foreach loop, it is giving error:
Property [id] does not exist on this collection instance.
But why do, i have to loop, if it is only getting one row from the boards table?? Any solution of doing it without running for each loop???
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire