Closed undjike closed 9 months ago
@nunomaduro any solution or workaround pls ?
@taylorotwell can you help, please?
In traditional Laravel applications, you are able to define your own middleware priority by placing the SubstituteBindings
at the end of your middleware stack. However, in Folio, you are not able to do that, and your own middleware will always run after model route binding.
As workaround, I suggest you to not use model route binding, and use regular route parameters.
Going to let @taylorotwell also give his opinion on this.
Agree - don't think this is possible with Folio at the moment. We always place the web middleware before all other user middleware.
in web.php
Route::middleware([
YOUR_MIDDELWARES,
])->group(function () {
Folio::route(PATH)
});
I'm using multi-db tenancy and this is working for me, I deleted FolioServiceProvider.php file
in
web.php
Route::middleware([ YOUR_MIDDELWARES, ])->group(function () { Folio::route(PATH) });
I'm using multi-db tenancy and this is working for me, I deleted FolioServiceProvider.php file
Great 👍, thanks. @taylorotwell should we take this one as the suitable way to achieve it? Is there any caution or downside doing it this way?
Folio Version
1.1.3
Laravel Version
10.22.0
PHP Version
8.2.3
Description
It seems like the Folio route model binding resolution happens before middlewares are applied 🤔. Thus, in my case, I had a middleware in charge of changing the current database connection dynamically.
I tried using the default routing system in the same project and things started working as expected. Back to Folio, it's no longer working (resolving the suitable database connection).
Steps To Reproduce
Using Folio, create a middleware that sets the default database connection. Route model binding will still use the default.