Check for DB table

This commit is contained in:
snipe 2016-05-14 15:05:28 -07:00
parent 1a14abed05
commit 9a8e4a55e7

View file

@ -5,6 +5,7 @@ namespace App\Http\Middleware;
use Closure; use Closure;
use Config; use Config;
use Route; use Route;
use Schema;
use App\Models\Setting; use App\Models\Setting;
class CheckLocale class CheckLocale
@ -20,19 +21,22 @@ class CheckLocale
public function handle($request, Closure $next, $guard = null) 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);
// User's preference // App setting preference
if (($request->user()) && ($request->user()->locale)) { } elseif ((Setting::getSettings()) && (Setting::getSettings()->locale!='')) {
\App::setLocale($request->user()->locale); \App::setLocale(Setting::getSettings()->locale);
// App setting preference // Default app setting
} elseif ((Setting::getSettings()) && (Setting::getSettings()->locale!='')) { } else {
\App::setLocale(Setting::getSettings()->locale); \App::setLocale(config('app.locale'));
}
// Default app setting
} else {
\App::setLocale(config('app.locale'));
} }
\App::setLocale(config('app.locale'));
return $next($request); return $next($request);
} }
} }