Answer the question
In order to leave comments, you need to log in
How to display a separate news by id?
There is a NewsItemController responsible for displaying news by id:
class NewsItemController extends Controller
{
public function show($id){
$items = News::findOrFail($id);
return view('item',compact('items'));
}
}
<table>
@foreach($items as $item)
<tr>
<td>{{$item->created_at}}</td>
<td>{{$item->title}}</td>
<td><a href="{{route('item',$item->id)}}">{{$item->title}}</a></td>
<td>{{$item->anons}}</td>
</tr>
@endforeach
</table>
@foreach($items as $item)
<tr>
<td>{{ $item['title']}}</td>
</tr>
@endforeach
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question