Reputation: 3797
I have the following route:
Route::resource('pools', 'PoolsController');
In the PoolsController
, the index
method works fine. If I open www.domain.com/pools it will run the content of index()
.
However, I'm running into an issue with the show()
method, specifically when trying to pass a parameter to it. I want to open www.domain.com/pools/show/12 where 12 is an ID from the database, but when I do this I get a NotFoundHttpException
. When I open www.domain.com/pools/show (without the parameter) it runs the method correctly - but this is obviously useless without the ID of the resource to be shown.
So I'm wondering why this isn't working. From what I've found online, this should be the way to pass a parameter to a controller method.
Can anyone enlighten me?
Upvotes: 0
Views: 2429
Reputation: 971
Obviously, route www.domain.com/pools/show/12
is not defined. What you have defined in your routes is resource('pools')
and that means you should browse to www.domain.com/pools/12
and 12
will be passed to the show()
method of the controller. When you open same url without parameters, show
will be passed to show()
method.
For further docs on RESTful resource controller visit this link
Upvotes: 1