1

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.

Iamzozo
  • 2,341
  • 18
  • 21
  • 1
    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 Mar 20 '15 at 15:42
  • Created a form, and using route('store'). Laravel recognize it's a valid route, so it creates an url to /. – Iamzozo Mar 23 '15 at 08:29

2 Answers2

1

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.

Community
  • 1
  • 1
FiddlingAway
  • 1,598
  • 3
  • 14
  • 30
0

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

IIllIIll
  • 504
  • 8
  • 25