<commit_before><?php

namespace App\Http\Middleware;

use Closure;
use Config;
use Route;
use App\Models\Setting;

class CheckLocale
{
  /**
   * Handle the locale for the user, default to settings otherwise
   *
   * @param  \Illuminate\Http\Request  $request
   * @param  \Closure  $next
   * @param  string|null  $guard
   * @return mixed
   */

    public function handle($request, Closure $next, $guard = null)
    {

      // User's preference
        if (($request->user()) && ($request->user()->locale)) {
            \App::setLocale($request->user()->locale);

        // App setting preference
        } elseif ((Setting::getSettings()) &&  (Setting::getSettings()->locale!='')) {
            \App::setLocale(Setting::getSettings()->locale);

        // Default app setting
        } else {
            \App::setLocale(config('app.locale'));
        }<commit_msg>Check for DB table<commit_after><?php

namespace App\Http\Middleware;

use Closure;
use Config;
use Route;
use Schema;
use App\Models\Setting;

class CheckLocale
{
  /**
   * Handle the locale for the user, default to settings otherwise
   *
   * @param  \Illuminate\Http\Request  $request
   * @param  \Closure  $next
   * @param  string|null  $guard
   * @return mixed
   */

    public function handle($request, Closure $next, $guard = null)
    {
        if (Schema::hasTable('settings')) {
            // User's preference
            if (($request->user()) && ($request->user()->locale)) {
                \App::setLocale($request->user()->locale);

                // App setting preference
            } elseif ((Setting::getSettings()) &&  (Setting::getSettings()->locale!='')) {
                \App::setLocale(Setting::getSettings()->locale);

                // Default app setting
            } else {
                \App::setLocale(config('app.locale'));
            }
        }
        \App::setLocale(config('app.locale'));

{'fraction_non_alphanumeric': 0.15673981191222572, 'fraction_numerical': 0.0, 'mean_word_length': 2.3537653239929948, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3849828', 'n_tokens_mistral': 550, 'n_tokens_neox': 538, 'n_words': 126}