Iamzozo
Iamzozo

Reputation: 2358

Laravel resource route to root

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.

Upvotes: 1

Views: 4584

Answers (2)

FiddlingAway
FiddlingAway

Reputation: 2253

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.

Upvotes: 1

IIllIIll
IIllIIll

Reputation: 504

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

Upvotes: 0

Related Questions