Support the ongoing development of Laravel.io →
Architecture
Last updated 2 years ago.
0

This could would mean if you navigate to /foo Laravel will load the FooController and run the code in the method called method(). The 'as' part of the array allows you to give the route a name.

You can then in your views create url's using the 'name' which will be like a alias to the GET 'foo' route.

URL::route('name'); // Automatically gets converted to /foo
Redirect::route('name'); // Redirects to /foo
Form::open( array('route' => 'name') ); // Opens a form and sets the action url to /foo

This can be handy for the developer, as when you may want to change the url segment from 'foo' to 'bar'. You have developed your application, and then your client decides they want to change the url for SEO purposes or some reason. By naming your routes using 'as', you can reference that route name, and change your URL and Laravel will automatically translate the URL throughout your application.

Hope that makes sense.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.