0
votes

How can I use a resource controller on the route of my site:

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

I hit the URL:

mysite.dev/some-slug-to-get-in-controller

And the show method doesnt work, just an error saying route doesnt exist.

I've checked the route list:

GET|HEAD  | /       | index   | TestController@index
POST      | /       | store   | TestController@store
GET|HEAD  | create  | create  | TestController@create
GET|HEAD  | {}      | show    | TestController@show
PUT|PATCH | {}      | update  | TestController@update
DELETE    | {}      | destroy | TestController@destroy
GET|HEAD  | {}/edit | edit    | TestController@edit
2

2 Answers

0
votes

You should change this to get the desired effect

Route::resource('/{slug}', 'TestController');
0
votes

In order to accomplish what you want you need to point your resource controller to some-slug-to-get-in-controller then your new route would be Route::resource('/some-slug-to-get-in-controller', 'TestController');

In your code your pointing the resource controller to / route, not the route that you are expecting to see.