I want to override env data
I overridethe mail service like this
config(['mail.host' => $emails_data->host]);
config(['mail.username' => $emails_data->username]);
config(['mail.password' => $emails_data->password]);
(new MailServiceProvider(app()))->register();
but if I do it for the app it don't work ?
config(['app.debug' => true]);
(new AppServiceProvider (app()))->register();
How can I override the env data while the app is running ?
I'm trying to add it in Middleware
class DebugBar
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
app('debugbar')->disable();
if ( Session::get('shop') == 'name' ) {
// register new config value
config(['app.debug' => true]);
(new AppServiceProvider (app()))->register();
//enable debuger
app('debugbar')->enable();
}
return $next($request);
}
}