Rainieren's avatar

Laravel - Route not accesable

Hello, I've come across something pretty weird. I made a route inside my web.php named Route::post('/vragen/create', 'PostController@store'); which is supposed to store a new post. But whenever I try to access that route, it tells me the page non-existent. My PostController's store method looks like this:

public function store(Request $request)
    {

        dd($request->all());


        return redirect($post->path());
    }

If have DD'd the method to see what will return but I can't even access that. What is causing this?, Because I can't create posts this way, If I try to make a post I get the error 'No Message' instead of the DD I am supposed to get returned. What is causing this?

This is my whole routes file

Route::get('/', 'PostController@index')->name('home');
Route::get('/vragen', 'PostController@showQuestions')->name('showQuestions');
Route::post('/vragen/create', 'PostController@store');
Route::get('/vragen/{channel}', 'PostController@index');
Route::get('/vragen/{channel}/{post}', 'PostController@show');
Route::post('/vragen/{channel}/{post}/replies', 'ReplyController@store')->name('addReply');
Route::post('/replies/{reply}/likes', 'LikesController@store');

Route::get('/aanbieders', 'CompanyController@index')->name('showCompanies');
Route::get('/aanbieders/{channel}/{CompanyPost}', 'CompanyController@show');

Route::get('logout', function() {
    Auth::logout();
    return redirect('/');
});

Auth::routes();

0 likes
4 replies
Talinon's avatar

What are you using to access the route? A web form submission?

Rainieren's avatar

Currently nothing, But If I do /vragen/create in my web browser I should see the DD right?

Talinon's avatar

No, because that would be a GET request.. you have defined it as a POST route.

ejdelmonico's avatar

You need to GET the page (form) first, then submit the form to the POST route. The GET request will display the view, the POST will process the submission.

Please or to participate in this conversation.