2022-01-05 12:30:05 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Classes\Settings;
|
|
|
|
|
|
|
|
use App\Models\Settings;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use Illuminate\Support\Facades\Cache;
|
2022-01-05 14:29:08 +00:00
|
|
|
use Illuminate\Support\Facades\Session;
|
2022-01-05 12:30:05 +00:00
|
|
|
|
2022-01-05 20:54:49 +00:00
|
|
|
class Language
|
2022-01-05 12:30:05 +00:00
|
|
|
{
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-14 17:06:24 +00:00
|
|
|
public function updateSettings(Request $request)
|
2022-01-05 12:30:05 +00:00
|
|
|
{
|
|
|
|
|
2022-01-05 14:03:29 +00:00
|
|
|
$values = [
|
2022-01-05 12:30:05 +00:00
|
|
|
//SETTINGS::VALUE => REQUEST-VALUE (coming from the html-form)
|
|
|
|
"SETTINGS::LOCALE:DEFAULT" => "defaultLanguage",
|
|
|
|
"SETTINGS::LOCALE:DYNAMIC" => "autotranslate",
|
|
|
|
"SETTINGS::LOCALE:CLIENTS_CAN_CHANGE" => "canClientChangeLanguage",
|
|
|
|
"SETTINGS::LOCALE:AVAILABLE" => "languages",
|
|
|
|
"SETTINGS::LOCALE:DATATABLES" => "datatable-language"
|
|
|
|
];
|
|
|
|
|
2022-01-07 07:04:33 +00:00
|
|
|
|
2022-01-05 14:03:29 +00:00
|
|
|
foreach ($values as $key => $value) {
|
2022-01-07 07:04:33 +00:00
|
|
|
$param = $request->get($value);
|
|
|
|
if (!$param) {
|
|
|
|
$param = "false";
|
|
|
|
}
|
2022-01-14 09:19:41 +00:00
|
|
|
Settings::where('key', $key)->updateOrCreate(['key' => $key], ['value' => $param]);
|
2022-01-05 14:03:29 +00:00
|
|
|
Cache::forget("setting" . ':' . $key);
|
2022-01-05 14:29:08 +00:00
|
|
|
Session::remove("locale");
|
2022-01-05 12:30:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-14 17:06:24 +00:00
|
|
|
return redirect(route('admin.settings.index') . '#language')->with('success', 'Language settings updated!');
|
2022-01-05 12:30:05 +00:00
|
|
|
}
|
|
|
|
}
|