【发布时间】:2014-08-10 05:57:43
【问题描述】:
请检查我的路由关于这个问题:
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 中搜索了确切的语法,但仍然不明白。
【问题讨论】:
-
简单 - 在路由中使用
{id}而不是(:id)。请参阅the docs 了解更多信息。 -
您应该将其发布为@alexrussell 的答案。
-
D'oh,太晚了 :) 老实说,我认为答案太小了,不能作为答案,但我想即使是小的答案也能完全回答问题。
-
谢谢大家的问题解决了
标签: laravel parameters laravel-4 routing