2

Im new to Laravel and just ran into a problem. I got these two routes.

Route::get('posts/{id}', 'PostController@show'); // To show the post Route::resource('users', 'UserController'); 

The problem is when i want to go to /posts/create tries to send me to the show function, but ofcourse can find the object. What am i doing wrong? So i thinks the word "create" is an id.

Hope you can help me out.

2
  • 1
    I'd personally use HTTP POST on 'posts/' to create a new one. Commented Apr 16, 2015 at 7:23
  • yes you will get "create" as passing variable in method show. You can handle it in controller or you can create an new route. Commented Apr 16, 2015 at 8:03

1 Answer 1

1

Right now you do not have RESTful path binded to correct route. I recommend you to define posts also as resource like this

Route::resource('posts', 'PostController'); 

Now you have all the RESTful paths automatically created and calling /posts/create will be handled by the create method in controller.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.