私はLaravelを学ぶのがとても新しいです。私はデータベースからデータを取得し、それを表示したい。できます。しかし、私はリンクとして(データベースからフェッチされた)タイトルを使用したいと思います。しかし、私はNotFoundHttpExceptionを取得します。ここ は私のルートはNotFoundHttpException Laravel
Route::get('articles', '[email protected]');
Route::get('articles/{id}', '[email protected]');
である私のコントローラは
class ArticleController extends Controller
{
public function index()
{
$articles=Article::all();
return view('articles.index', compact('articles'));
} //
public function show($id){
$article=Article::find($id);
return view('articles.show',compact('article'));
}
}
ビューが
@extends('new_welcome')
@section('content')
<h1> Articles </h1>
@foreach($articles as $article)
<article>
<h2>
<a href="{url ('/articles',$article->id)}">{{$article->title}}</a>
</h2>
<div class="body">{{ $article->body}}</div>
</article>
@endforeach
@stop
である誰かが、この場合には私を助けることができますか?あなたは1つの中括弧(ブレードエンジンはそれをスキップ) "を食べる" きのためにあなたの問題がある
、あなたは '指数()'関数で3 'return'文を持っている... –
エラーはそれがルートを見つけることができないことを意味し、あなたが入力しているURLは何ですか? –
2つの場合、個々の 'article'を表示するために定義されたルートはありません。これは' NotFoundHttpException'が出てくる場所です。 –