Update middleware code

This commit is contained in:
Dane Everitt 2018-09-03 15:17:53 -07:00
parent 9706a8dc34
commit fd49e524c8
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
2 changed files with 9 additions and 33 deletions

View file

@ -1,19 +1,10 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Foundation\Application;
use Illuminate\Contracts\Config\Repository;
class LanguageMiddleware
{
@ -22,25 +13,18 @@ class LanguageMiddleware
*/
private $app;
/**
* @var \Illuminate\Contracts\Config\Repository
*/
private $config;
/**
* LanguageMiddleware constructor.
*
* @param \Illuminate\Foundation\Application $app
* @param \Illuminate\Contracts\Config\Repository $config
* @param \Illuminate\Foundation\Application $app
*/
public function __construct(Application $app, Repository $config)
public function __construct(Application $app)
{
$this->app = $app;
$this->config = $config;
}
/**
* Handle an incoming request.
* Handle an incoming request and set the user's preferred language.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
@ -48,7 +32,7 @@ class LanguageMiddleware
*/
public function handle(Request $request, Closure $next)
{
$this->app->setLocale($request->user()->language ?? $this->config->get('app.locale', 'en'));
$this->app->setLocale($request->user()->language ?? config('app.locale', 'en'));
return $next($request);
}