So I've been working on an app that lived on the domain root and now has to work on /admin. So URLs like domain.com/[resource]
should now be domain.com/admin/[resource]
. I didn't thought this very well before since I assumed that this had to be a very easy fix on Laravel. After all, that's one of the main reasons for not hardcoding routes, right?
So my routes.php file looked something like:
Route::group(['before' => 'auth'], function() {
Route::resource('books', 'BooksController');
... more resources here ...
});
Going through the docs I found that 'prefix' => 'admin'
would do the trick:
Route::group(['prefix' => 'admin', 'before' => 'auth'], function() {
Route::resource('books', 'BooksController');
... more resources here ...
});
But it turns out that every route name get's changed from books.{action}
to admin.books.{action}
which requires me to change the whole app. Regexing would be dangerous and doing it manually would be annoying. Laravel was supposed to help with this! Or am I missing something?