1
votes

Is it possible to set a resource route to root?

Like:

Route::resource('/', 'HomeController');

So I could use these urls:

/
/create
/214
/214/edit

I've tried, create, index works, route('store') recognized, but doesn't call store the function and redirects to home.

2
How did you hit the store method? Keep in mind that it's a post route and won't work if you try to hit it with your browser.user1669496
Created a form, and using route('store'). Laravel recognize it's a valid route, so it creates an url to /.Iamzozo

2 Answers

1
votes

Not sure if you still need help with this one, since it's been more than a year. Try putting this in your blade file.

<form action="{{ route('store') }}" method="POST">

I've had a similar problem with my code. My original form had this, at the very beginning (using default documentation code here):

<form action="{{ route('photo.store') }}>

which, after trying it out, didn't work as I would expect - nothing was being stored. After making sure that the rest of the code was OK, one of my colleagues suggested that I type in the method type, since the default method is GET, and you need the POST method for storing.

0
votes

All you need to do is Route::resource('/', 'HomeController');.