我無法使用laravel將我的表單發佈到我的數據庫。當我點擊提交時,它顯示了RouteCollection.php第218.行中的錯誤MethodNotAllowedHttpException。我的HTML代碼如下所示。我已經定義瞭如下所示的路線,並且我也粘貼了包含商店功能的PostController。RouteCollection.php中的MethodNotAllowedHttpException行218:Laravel
<div class="blog-page blog-content-2">
<div class="row">
<div class="col-lg-9">
<div class="blog-single-content bordered blog-container">
<div class="blog-comments">
<h3 class="sbold blog-comments-title">Leave A Comment</h3>
<form method="post" action="store">
<div class="form-group">
<input name="title" type="text" placeholder="Your Name" class="form-control c-square"> </div>
<div class="form-group">
<textarea name="body" rows="8" name="message" placeholder="Write comment here ..." class="form-control c-square"></textarea>
</div>
<div class="form-group">
<button type="submit" class="btn blue uppercase btn-md sbold btn-block">Submit</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
這是我的路線頁面
Route::resource('posts', 'PostController');
這是一個包含了是假設將數據存儲到數據庫中的存儲功能的PostController中。
public function store(Request $request)
{
//Validate the data
$this->Validate($request, array(
'title'=>'required|max:255',
'body'=>'required'
));
//Store the data into the database
$post = new Post;
$post->title = $request->get('title');
$post->body = $request->get('body');
$post->save();
//redirect to another page
return redirect()->route('posts.show', $post->id);
}
你能發表您的'''routes.php文件'''? – aceraven777
試試這條路線:Route :: post('store','PostController @ store') – rad11