for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace BBSLab\NovaTranslation\Http\Middleware;
use BBSLab\NovaTranslation\Models\Locale;
use Illuminate\Support\Facades\Session;
class SetLocale
{
/**
* Handle the incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return \Illuminate\Http\Response
*/
public function handle($request, $next)
if (Session::has('nova_locale')) {
$locale = Session::get('nova_locale');
} else {
$browserLocale = substr($request->server('HTTP_ACCEPT_LANGUAGE'), 0, 2);
$databaseLocale = Locale::query()->select('id')->where('iso', '=', $browserLocale)->first();
select()
Illuminate\Database\Eloquent\Builder
createSelectWithConstraint()
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.
if (! empty($databaseLocale)) {
$locale = $browserLocale;
$locale = config('app.locale');
}
Session::put('nova_locale', $locale);
app()->setLocale($locale);
return $next($request);
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.