Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resourceful Controller Named Routes Confusion #472

Closed
JeffreyWay opened this issue Mar 1, 2013 · 2 comments
Closed

Resourceful Controller Named Routes Confusion #472

JeffreyWay opened this issue Mar 1, 2013 · 2 comments

Comments

@JeffreyWay
Copy link
Contributor

Let's say that you create a resourceful controller for photos.

Route::resource('photos', 'PhotosController');

Laravel will then automatically create the necessary named routes, like photos.index, photos.show, etc.

The only confusion (unless I'm being dense) stems from generating URLs and such. For example, if I want to generate a URL to display one photo, I'd expect to do:

route('photos.show', ['id' => $id]);

However, that won't work. Laravel wants me to use the photos key instead.

route('photos.show', ['photos' => $id]);

That's not intuitive. Can we use {id} instead of {photos}? Or am I missing something simple?

http://enva.to/ViuzRp

@JeffreyWay
Copy link
Contributor Author

Of course, I can just pass the array with no key...

@franzliedke
Copy link
Contributor

Awesome, I was confused about this, too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants