Laravel's routing doesn't seem to be working as expected? From what I understand, if I intend to override a route, all I need to do is to put the expected route before the other one.
What I have is something like this:
Route::group(array('before'=>'defaultLoads'), function(){
Route::post('newsletter', 'NewsletterController@store');
Route::group(array('before'=>'login'), function(){
Route::resource('newsletter','NewsletterController');
}
});
Which I assumed that if i post to this route http://domain.com/newsletter
it should only run the defaultLoads route filter.
However, when I run php artisan routes
, I get this:
| | POST newsletter | newsletter.store | NewsletterController@store | defaultLoads, login | |
Although it reads the route correctly (php artisan loads that correct route in the correct place) but the resource route's filter affected the route even when it's not in that filter group.
So my question:
Is this how Laravel works?
If so, is it possible for me to override that POST->newsletter route without actually doing the following?
Route::group(array('before'=>'defaultLoads'), function(){ Route::post('newsletter', 'NewsletterController@store'); Route::group(array('before'=>'login'), function(){ Route::get('newsletter','NewsletterController@get'); Route::get('newsletter/{id}', 'NewsletterController@show'); //etc all the rest of the routes except post }});