I have created a package in Laravel 5.4 that sets up a basic backoffice. This package contains several routes that are using controllers from within the package. What I want to be able to do is to override the package defined routes in my application in order to plug custom controllers. For example, if I have a route
Route::get('login', [
'as' => 'admin.login',
'uses' => 'Auth\LoginController@showLoginForm'
]);
defined in my package that will use the Vendor\Package\Controllers\Auth\LoginController
I want to defined a route for my application that will override that one and use the App\Controllers\Auth\LoginController
.
Doing the obvious approach of defining the route in app routes files fails for the app routes files are run before the package routes file, so the package definition will prevail.
Is there any way to accomplish something of this kind?
I also tried to get the particular route in the RouteServiceProvider
and use the method uses
to set the controller that should be used to resolve it, like this
public function boot()
{
parent::boot();
Route::get('admin.login')->uses('App\Http\Controllers\Admin\Auth\LoginController@showLoginForm');
}
but this also fails to accomplish what is pretended.
Any clues on what I am doing wrong?