Comments (16)
+1. Would be awesome to have.
Perhaps URL::resource(resource route, method, parameters) would be better as the methods in our controller class are not prefixed with the resource name?
Just a thought.
from framework.
Shawn - do you think something like this would even be necessary, if the resourceful controller generator automatically created the named routes? I think I might prefer to stick with:
$url = URL::to_route( 'edit_user_path', array($id) );
...One less new thing to learn, and fully readable.
from framework.
Yea, I think you're right.
On Mon, Jan 14, 2013 at 3:47 PM, Jeffrey Way [email protected]:
Shawn - do you think something like this would even be necessary, if the
resourceful controller generator automatically created the named routes? I
think I might prefer to stick with:$url = URL::to_route( 'edit_user_path', array($id) );
...One less new thing to learn, and fully readable.
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/37#issuecomment-12221088.
Shawn McCool | Big Name
[email protected]
heybigname.com
from framework.
I agree, providing we have named routes for resources. Also means that Meido's HTML package can still be used to create links.
from framework.
Coming back around to this getting ready to implement something. What do you guys think about using "dot" syntax for the route names on resourceful routes?
Like...
URL::route('user.edit', [1]);
URL::route('user'); // would point to index...
Also planning on implementing nested resources, so like:
URL::route('magazine.ads.edit', [1, 2]); // 1 being the magazine ID and 2 being the ad ID
from framework.
I suggest dots because we use those throughout the framework for other things and to indicate nesting, etc.
from framework.
I don't think that it's a bad convention. If you create a new convention for every type of thing then you're going to run out of delimiters quickly.
from framework.
@taylorotwell Am I correct in assuming that we reference the controller method? Eg. URL::route('user.destroy', [1]); ? Just to clarify, routing to the action, not a named route variant.
from framework.
This looks cool. And I agree, dots feel right.
from framework.
@niallobrien the name happens to match the controller action, yeah, but it's a true named route. I just thought it would be convenient if they matched the action names.
from framework.
I think that would work just fine. My only concern might relate to whether it confuses people. For URL::route
, they'd use dot notation (preferred). For URL::action
, they'd use @. Not a big deal, though.
Or, I wonder which would be considered more readable/recognizable by the community:
URL::route('user.create');
// or
URL::route('create_user');
Either way, I think both fit nicely.
from framework.
Good point @JeffreyWay. People are used to @ representing a controller action.
from framework.
Using @
could still be a tad confusing because it's not really generating anything from a controller action (even though it kinda looks that way), it's a true named route. I think we'll just stick with dots and see how it's received.
from framework.
This has been implemented. Resource routes also use wildcards matching the resource names so that they may be easily used with Route::model
. Also, nested resources are now supported using "dot" syntax as well:
Route::resource('magazine.photo', 'PhotoController');
from framework.
@taylorotwell I noted that due to this change, I am not able to workout my api routes which is actually segmented under "api/" path for all my resources, and it is now that route::resource() no longer accept slash.
Is it possible to workout a solution as I have proposed here #181 and #170 was also taken note of this issue.
from framework.
Resource routes also use wildcards matching the resource names so that they may be easily used with Route::model
Does that explain #182?
from framework.
Related Issues (20)
- SQLite `whereJsonContains` grammar not working correctly HOT 8
- Max file size rule is lost if `types` used after HOT 2
- Null exception when sending a mail defining envelope without `from` HOT 3
- eloquent created event fired too early HOT 1
- Eloquent's `ArrayObject` breaks default behavior of json encoding HOT 1
- Docs Command can not be cancelled when offline HOT 6
- New Observe Attribute work has broken my model HOT 2
- whereHas, withWhereHas doesn't work properly with "withAvg.... " methods. HOT 2
- whereHas, withWhereHas doesn't work properly with "withAvg.... " methods. HOT 4
- 'array' validation rule passes when the value is an empty string and required_array_keys passes as long as at least 1 key exists HOT 1
- Error in observe function of HasEvent trait due to model dependency handling in Laravel 10.44.0 HOT 1
- [v11] Spark middleware does not exist HOT 4
- page expired when login HOT 1
- Incorrect behaviour "SQLite doesn't support multiple calls to dropColumn / renameColumn in a single modification." HOT 3
- Sessions table is created even though driver is set to redis HOT 8
- My subdomain only index page works but others all page not works error 500
- Race condition when scheduling commands with withoutOverlapping() using Redis/Memcached HOT 3
- Integration of "whereLike & whereHasLike" Syntax in Eloquent Builder
- ### Laravel Version HOT 1
- The method throwUnless() does not exists in Http response class HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from framework.