Reputation: 427
Route::resource('posts','PostsController');
Route::post('posts/changeStatus', array('as' => 'changeStatus', 'uses' => 'PostsController@changeStatus'));
The code provided is a route from my laravel project. I did not write this code and I am attempting to understand what they have done. I cannot find anywhere in the documentation the reason for using the key value store with 'as' and 'uses'. I would normally write the code below, however this is not working with the ajax-crud setup.
Route::post('posts/changeStatus', 'PostsController@changeStatus');
Upvotes: 1
Views: 3529
Reputation: 163898
From the docs:
Named routes allow you to conveniently generate URLs or redirects for a specific route. You may specify a name for a route using the
as
array key when defining the route
as
is the name of that route. You can use it to create an URL with route('changeStatus')
helper.
uses
is controller method (action) for the route.
https://laravel.com/docs/5.1/routing#named-routes
Upvotes: 1