【发布时间】:2014-09-22 15:05:34
【问题描述】:
我正在尝试显示从表单提交的信息以创建留言板。我在 laravel 框架中使用 php。我正在使用表单、记录和存储库。每当我尝试显示内容时,我都会收到以下错误 Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException。
这里是控制器:
/**
* Display a listing of the resource.
* GET /messages
*
* @return Response
*/
public function create()
{
return View::make('comments.create');
}
public function show($comment)
{
$message_id = $this->messageRepository->find($comment);
return View::make('comments.show')->with('comment', $message_id);
}
/**
* Store a newly created resource in storage.
* POST /messaages
*
* @return Response
*/
public function store()
{
$data = Input::all() ;
$this->messageForm->validate($data);
$messageRecord = new MessageRecord;
$messageRecord->comment = $data['comment'];
Return "Comment created";
}
}
这是导致问题的视图:
<p>$comment</p>
我没有使用路线,但我把它放在一起:
Route::resource('/message', 'MessageController');
【问题讨论】:
-
错误信息表明到控制器方法的路由不正确。能否也提供 routes.php 的内容?
-
我没有它的路线,因为两者都通过一个有自己路线的既定页面。
-
就像观察者所说,使用 routes.php 文件更新您的帖子将清除问题,以便我们提供答案。
标签: php symfony laravel repository