Created
October 11, 2020 14:20
-
-
Save Aslam97/57e1d2bcec53e20e8ef8d16e65f14cf8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Middleware; | |
use Closure; | |
use Illuminate\Support\Facades\App; | |
use Illuminate\Support\Facades\Session; | |
class LangMiddleware | |
{ | |
/** | |
* lang | |
* | |
* @var mixed | |
*/ | |
private $lang; | |
/** | |
* __construct | |
* | |
* @return void | |
*/ | |
public function __construct() | |
{ | |
$this->lang = Session::get('locale'); | |
} | |
/** | |
* Handle an incoming request. | |
* | |
* @param \Illuminate\Http\Request $request | |
* @param \Closure $next | |
* @return mixed | |
*/ | |
public function handle($request, Closure $next) | |
{ | |
if (Session::has('locale')) { | |
App::setLocale($this->lang); | |
} | |
return $next($request); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment