Skip to content

Instantly share code, notes, and snippets.

@paulofreitas
Last active September 23, 2017 20:23
Show Gist options
  • Save paulofreitas/206cd9684d8f72af8755e85307e804ba to your computer and use it in GitHub Desktop.
Save paulofreitas/206cd9684d8f72af8755e85307e804ba to your computer and use it in GitHub Desktop.
<?php
namespace App\Http\Middleware;
use Closure;
class SetLocale
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
app()->setLocale(optional(auth()->user())->lang ?? config('app.locale'));
return $next($request);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment