Route::resource('admin/invoice', 'InvoiceController');
Route::get('admin/invoice/settings', array(
'as' => 'admin.invoice.settings',
'uses' => 'InvoiceController@settings'
));
The code above directs me to the show method in my controller. However, when i switch the order of route (as the displayed in the code block below). My setting route display correctly.
Route::get('admin/invoice/settings', array(
'as' => 'admin.invoice.settings',
'uses' => 'InvoiceController@settings'
));
Route::resource('admin/invoice', 'InvoiceController');
Is this considered a bug for laravel?
It's not a bug. It's expected behaviour.
You don't say, but I assume you're issuing a GET request to http://yoursite.tld/admin/invoice/settings.
In your first example that satisfies the pattern admin/invoice/{resource} which maps to the show() method. This is explained here in the docs.
In the second example, your custom-defined route is the first match giving the result that you were hoping for.
To avoid this sort of confusion, it's generally best to put your most specific route definitions first.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community