I'm currently working on a forum system (laravel 5.3) and I get an error, probably because I have something set wrong in my routes settings.
<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| This file is where you may define all of the routes that are handled
| by your application. Just tell Laravel the URIs it should respond
| to using a Closure or controller method. Build something great!
|
*/
Route::get('/', 'IndexController@index')->name('index');
Auth::routes();
Route::get('/index', 'IndexController@index')->name('index');
Route::get('/thread/{id}', 'ThreadController@showThread')->name('thread_detail');
Route::get('/privacybeleid', 'PagesController@privacyPolicy');
Route::get('/over-ons', 'PagesController@about');
Route::group(['middleware' => 'auth'], function() {
Route::get('/thread/nieuw', 'ThreadController@showForm')->name('thread_form');
Route::post('/thread', 'ThreadController@create')->name('create_thread');
Route::post('/thread/{id}/reply', 'CommentController@create')->name('create_comment');
});
When I want to see a thread (website.com/thread/{id}) then I get no error, everything works as it should. But when I want to add a new comment on a topic (website.com/thread/{id}/reply) or create a new topic (website.com/thread/nieuw) I get the following error:
MethodNotAllowedHttpException in RouteCollection.php line 218:
I've tried to change Route::get to Route::post (and vice versa), but then I get another error.
When I go to website.com/thread/nieuw , then I see nothing (page does not exist). Even if I have a session (logged in).
By the way: there are tips for the routes/web.php? Let me know
Note: I am dutch so "nieuw" means "new"
Try to put this route:
Route::post('/thread/{id}/reply', 'CommentController@create')->name('create_comment');
Before this one:
Route::get('/thread/{id}', 'ThreadController@showThread')->name('thread_detail');