Unable to use backpack_middleware() in routes
tabacitu opened this issue · 1 comments
So I've tried to do this:
<?php
/*
|--------------------------------------------------------------------------
| Backpack\BackupManager Routes
|--------------------------------------------------------------------------
|
| This file is where you may define all of the routes that are
| handled by the Backpack\BackupManager package.
|
*/
Route::group([
'namespace' => 'Backpack\BackupManager\app\Http\Controllers',
'prefix' => config('backpack.base.route_prefix', 'admin'),
- 'middleware' => ['web', 'admin'],
+ 'middleware' => ['web', backpack_middleware()],
], function () {
Route::get('backup', 'BackupController@index');
Route::put('backup/create', 'BackupController@create');
Route::get('backup/download/{file_name?}', 'BackupController@download');
Route::delete('backup/delete/{file_name?}', 'BackupController@delete')->where('file_name', '(.*)');
});
But it doesn't know that helpers exists:
As far as I can tell, this is because the Laravel auto-discovery loads packages alphabetically, so backpack/backupmanager
is loaded before backpack/base
. Hence, no base
helpers available in that routes file.
Does anybody know a way to define the order for package auto-discovery? I would like for backpack/backupmanager to be discovered after backpack/base.
Thanks, cheers!
PS. No, setting backpack/base as a requirement for backpack/backupmanager did not fix the issue, like I expected. The alphabetical order persists.
Fixed with the latest version. A composer update
should do it for anyone wondering (it will pull 1.4.1 or later).
The problem was that the Backpack\Base helpers were loaded in the boot()
method, and not in register()
. Silly me :-)