when I try to insert the third parameter in the handle method, I get the following error:
'Too few arguments to function AppHttpMiddlewareLocale::handle(), 2 passed in /Applications/MAMP/htdocs/weather-app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php on line 167 and exactly 3 expected'
How can I fix it?
My middleware:
namespace AppHttpMiddleware;
use AppServicesSettingsService;
use Closure;
use IlluminateHttpRequest;
class Locale
{
/**
* Handle an incoming request.
*
* @param IlluminateHttpRequest $request
* @param Closure $next
* @param SettingsService $settingsService
* @return mixed
*/
public function handle(Request $request, Closure $next, SettingsService $settingsService): mixed
{
$locale = $settingsService->get('language', app()->getLocale());
app()->setLocale($locale);
return $next($request);
}
}
Kernel:
'web' => [
AppHttpMiddlewareEncryptCookies::class,
IlluminateCookieMiddlewareAddQueuedCookiesToResponse::class,
IlluminateSessionMiddlewareStartSession::class,
// IlluminateSessionMiddlewareAuthenticateSession::class,
IlluminateViewMiddlewareShareErrorsFromSession::class,
AppHttpMiddlewareVerifyCsrfToken::class,
IlluminateRoutingMiddlewareSubstituteBindings::class,
AppHttpMiddlewareLocale::class,
],
question from:
https://stackoverflow.com/questions/65853513/too-few-arguments-to-function-app-http-middleware-localehandle-laravel-8 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…