Does anyone know of any way in Laravel 4 which combines these 2 lines into one?
Route::get('login', 'AuthController@getLogin'); Route::post('login', 'AuthController@postLogin');
So instead of having to write both you only have to write one since their both using the 'same' method but also the URL remains as site.com/login
instead of a redirect to site.com/auth/login
?
I'm curious since I remember CI has something like that where the URL remains the same and the controller is never shown:
$route['(method1|method2)'] = 'controller/$1';
Laravel route model binding provides a convenient way to automatically inject the model instances directly into your routes. For example, instead of injecting a user's ID, you can inject the entire User model instance that matches the given ID.
For a start it is using a named route. This means that the link between the form and its controller are not dictated by the url that the user sees. The next advantage is that you can pass additional parameters into the route helper and it will put those in the correct place in the form action.
Route Parameters Laravel provides two ways of capturing the passed parameter: Required parameter. Optional Parameter.
The docs say...
Route::match(array('GET', 'POST'), '/', function() { return 'Hello World'; });
source: http://laravel.com/docs/routing
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With