【发布时间】:2022-01-16 04:57:31
【问题描述】:
我想查看一些数据,但我收到此错误 Route [news.shownewspublic] not defined。 (查看:C:\xampp\htdocs\ContentBaseApp - 1.0.2\resources\views\news\indexnewspublic.blade.php) 这是我的资源\视图\新闻文件夹 这是 resources\views\news\indexnewspublic.blade.php
@foreach ($news as $news)
<a class="btn btn-outline-info" href="{{route('news.shownewspublic'),$news->id}}">
<img src="/image/{{ $news->image }}" width="100px" class="col-2">
<div class="col-2" style="color: #1d2124">
<strong>App Name:- {{ $news->name }}</strong>
</div>
</a>
@endforeach
这是我的 NewsController.php
public function indexnewspublic()
{
$news = News::latest()->paginate(5);
return view('news.indexnewspublic',compact('news'))
->with('i', (request()->input('page', 1) - 1) * 5);
}
public function shownewspublic(News $news)
{
return view('news.shownewspublic',compact('news'));
}
这是 web.php
Route::resource('news', NewsController::class);
Route::get('/indexnewspublic', [NewsController::class, 'indexnewspublic']);
Route::get('/shownewspublic', [NewsController::class, 'shownewspublic']);
【问题讨论】:
标签: laravel-8