2016-09-13 98 views
0

我是Laravel的初學者,我需要您的幫助。我已成功在索引頁上顯示了我的發佈者控制器的內容,但我希望能夠點擊每個帖子並將其顯示在另一個頁面上。我正在使用Laravel 5.2。Laravel 5.2 RouteFollection.php中的NotFoundHttpException單行視圖中的行161

這裏是我的控制器:

`

public function show($id) 
{ 
$post= Post::find($id); 
return View::make('posts.viewpost')->with('post', $post); 
    } 

`

這裏是我的路線:

Route::get('posts/viewpost/{id}','[email protected]');

這裏是我的索引頁,目前顯示的所有帖子:

`

@foreach($posts as $post) 
{{$post->title}} 
{{$post->description}} 
<a href="{{ url('posts/viewpost', $post->id) }}"> Read More</a> 
@endforeach 

`

我希望能夠點擊「更多」,並有一個新的頁面上顯示的每個崗位viewpost.blade.php

項目運行後我試圖點擊每個帖子,我不斷收到此錯誤頁面: shown in this image.

我真的不明白爲什麼每次點擊第電子郵件,請大家幫助我。感謝您期待您的幫助。

回答

0

嘗試用網址::到可能其並沒有把你的基本路徑 與此代碼

<a href="{{ URL::to('posts/viewpost/'.$post->id) }}"> 
+0

感謝您的幫助,我已經能夠弄明白 – Ehi

0

謝謝你們,我已經能夠弄明白嘗試。

我不得不更新這一行:

<a href="{{ url('posts/viewpost', $post->id) }}"> Read More</a> 

這樣:

<a href="{{ url('posts', $post->id) }}"> Read More</a> 
相關問題