Laravel 4中的路由参数

rivai04

请检查我关于此问题的路由:

    Route::any('author/(:id)' , array('as'=>'author', 'uses'=>'AuthorsController@view'));

和控制器:

    public function view($id){
    return View::make('authors.view')
        ->with('title','Ini Halaman Penulis Berdasarkan Urutan Abjad')
        ->with('author', Author::find($id));

view.blade.php:

    @extends('layouts.default')

    @section('content')
      <h1>{{ $author->name }}</h1>
      <p>{{ $author->bio }}</p>
      <p>{{ $author->updated_at }}</p>
    @stop

我知道旧laravel是否提供了这种语法,我是否从最新laravel中搜索了确切的语法,但仍然不了解。

马克·比奇

只需将您的路线更改为

Route::any('author/{id}' , array('as'=>'author', 'uses'=>'AuthorsController@view'));

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章