和前面一樣,我們要在 app/controllers/ArticlesController.php 文件中更改 show 動作,以及相應的視圖文件。
~~~
public function show($id)
{
$article = Article::find($id);
return View::make('articles.show', compact('article'));
}
~~~
然后,新建 app/views/articles/show.blade.php 文件,寫入下面的代碼:
~~~
<p>
<strong>Title:</strong>
{{ $article->title }}
</p>
<p>
<strong>Text:</strong>
{{ $article->text }}
</p>
~~~
做了以上修改后,就能真正的新建文章了。訪問 http://localhost:8000/articles/create ,自己試試。