2014-05-06 31 views
1

任何人都可以看看這個,無法弄清楚,爲什麼最後一行導致以下錯誤:語法錯誤信息 - >在Laravel

syntax error, unexpected '(', expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$'

public function show($id) 
{ 
    $post = Post::find($id); 
    $date = $post->created_at; 
    setlocale(LC_TIME, 'GB'); 
    $date = $date->formatlocalized('%A %d %B %Y'); 
    return View::make('posts.show')->('post', $post)with->('date', $date); 
} 

回答

1

擴大對@ Log1c最初的回答,你打開一個括號不了了之:

return View::make('posts.show')->('post', $post)->with('date', $date); 
          // ^-- HERE, there's no function call 

可能是你想用的with()那裏嗎?

return View::make('posts.show')->with('post', $post)->with('date', $date); 
+0

對不起,這是倉促,沒關係:) –

+0

啊謝謝,似乎已經排序它。乾杯。 –

0

相反:

return View::make('posts.show')->('post', $post)with->('date', $date); 

它應該是:012

return View::make('posts.show')->with('post', $post)->with('date', $date); 

改變位置,因爲你正在調用方法with(),調用方法如with->()是無效的語法,並且還添加一個with()

+0

嗨,謝謝,我嘗試了你的建議,但仍然得到相同的錯誤。 http://steppic.com/show/5e8e0f33b20aad5957bb86d9e9d08a1f.html –

+0

哎呀,我錯過了一個'()'嘗試更新ans –

+0

感謝您的幫助,似乎工作:) –

相關問題