경로날이 경로 오류
Route::get('board/{category}', ['as' => 'board.showByCate', 'uses' =>'[email protected]']);
컨트롤러
public function cate() {
$categories = category::all();
return view('welcome', compact('categories'));
}
public function showByCate($category) {
$boards = board::where('category', '=', $category)->orderBy('created_at', 'desc')->paginate(3)->get();
$allBoards = board::orderBy('created_at', 'desc')->paginate(3);
return view('board.index', compact('boards', 'allBoards'));
}
보기이 코드는 오류를 가져
<ul class="list-inline">
<li>
<a href="{{ route('board.showByCate') }}">all</a>
</li>
@foreach($categories as $category)
<li>
<a href="{{ route('board.showByCate', $category->category) }}">
{{$category->category}}
</a>
</li>
@endforeach
</ul>
.. UrlGenerationException에서 1/2 UrlGenerationException를 해결하는 데 도움이 바랍니다. PHP 라인 17 : 필수 매개 변수 누락 [Route : board.showByCate] [URI : 게시판/{카테고리}]. 2/2 UrlGenerationException.php 17 행의 오류 : [Route : board.showByCate] [URI : board/{category}]에 필수 매개 변수가 누락되었습니다. (보기 : /home/vagrant/Code/Laravel/resources/views/welcome.blade.php) 나는 //
당신은 더 나은 귀하의 문제를 표현하는 제목을 수정할 수 있습니다. 다른 사람들이 미래에 가질 수있는 질문이므로 기억해 두는 것이 좋습니다. – BVengerov
보기에서 $ category-> 카테고리를 경로에 연결하십시오. '{{route ('board.showByCate.'. $ category-> category)}}'' – bwaaaaaa