2022-03-05 16:02:12 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
use App\Models\Settings;
|
|
|
|
use Illuminate\Http\Request;
|
2022-03-05 16:58:25 +01:00
|
|
|
use Illuminate\Support\Facades\Cache;
|
2022-03-05 16:02:12 +01:00
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
use Illuminate\Support\Facades\Session;
|
|
|
|
|
|
|
|
class SettingsController extends Controller
|
|
|
|
{
|
|
|
|
public function index()
|
|
|
|
{
|
|
|
|
$setting = DB::table('settings')
|
|
|
|
->where('id', '=', 1)
|
|
|
|
->get();
|
|
|
|
|
|
|
|
return view('settings.index', compact(['setting']));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function update(Request $request, Settings $settings)
|
|
|
|
{
|
|
|
|
$request->validate([
|
2022-05-09 07:57:02 +02:00
|
|
|
'dark_mode' => 'required|boolean',
|
2022-03-05 16:02:12 +01:00
|
|
|
'show_versions_footer' => 'required|boolean',
|
|
|
|
'show_server_value_ip' => 'required|boolean',
|
|
|
|
'show_server_value_hostname' => 'required|boolean',
|
|
|
|
'show_server_value_provider' => 'required|boolean',
|
|
|
|
'show_server_value_location' => 'required|boolean',
|
|
|
|
'show_server_value_price' => 'required|boolean',
|
2022-03-05 16:58:25 +01:00
|
|
|
'show_server_value_yabs' => 'required|boolean',
|
2022-07-20 04:51:45 +02:00
|
|
|
'save_yabs_as_txt' => 'required|boolean',
|
2022-03-05 16:58:25 +01:00
|
|
|
'default_currency' => 'required',
|
2022-03-09 03:41:12 +01:00
|
|
|
'default_server_os' => 'required',
|
|
|
|
'due_soon_amount' => 'required|integer|between:0,12',
|
2022-05-29 08:46:55 +02:00
|
|
|
'recently_added_amount' => 'required|integer|between:0,12',
|
2022-10-04 05:35:46 +02:00
|
|
|
'currency' => 'required|string|size:3',
|
|
|
|
'sort_on' => 'required|integer|between:1,10',
|
2022-03-05 16:02:12 +01:00
|
|
|
]);
|
|
|
|
|
|
|
|
DB::table('settings')
|
|
|
|
->where('id', 1)
|
|
|
|
->update([
|
2022-05-09 07:57:02 +02:00
|
|
|
'dark_mode' => $request->dark_mode,
|
2022-03-05 16:02:12 +01:00
|
|
|
'show_versions_footer' => $request->show_versions_footer,
|
|
|
|
'show_servers_public' => $request->show_servers_public,
|
|
|
|
'show_server_value_ip' => $request->show_server_value_ip,
|
|
|
|
'show_server_value_hostname' => $request->show_server_value_hostname,
|
|
|
|
'show_server_value_provider' => $request->show_server_value_provider,
|
|
|
|
'show_server_value_location' => $request->show_server_value_location,
|
|
|
|
'show_server_value_price' => $request->show_server_value_price,
|
2022-03-05 16:58:25 +01:00
|
|
|
'show_server_value_yabs' => $request->show_server_value_yabs,
|
2022-07-20 04:51:45 +02:00
|
|
|
'save_yabs_as_txt' => $request->save_yabs_as_txt,
|
2022-03-05 16:58:25 +01:00
|
|
|
'default_currency' => $request->default_currency,
|
2022-03-09 03:41:12 +01:00
|
|
|
'default_server_os' => $request->default_server_os,
|
|
|
|
'due_soon_amount' => $request->due_soon_amount,
|
2022-05-29 08:46:55 +02:00
|
|
|
'recently_added_amount' => $request->recently_added_amount,
|
|
|
|
'dashboard_currency' => $request->currency,
|
2022-10-04 05:35:46 +02:00
|
|
|
'sort_on' => $request->sort_on,
|
2022-03-05 16:02:12 +01:00
|
|
|
]);
|
|
|
|
|
2022-03-09 03:41:12 +01:00
|
|
|
Cache::forget('due_soon');//Main page due_soon cache
|
|
|
|
Cache::forget('recently_added');//Main page recently_added cache
|
2022-05-29 08:56:13 +02:00
|
|
|
Cache::forget('pricing_breakdown');//Main page pricing breakdown
|
2022-03-09 03:41:12 +01:00
|
|
|
|
2022-03-05 16:58:25 +01:00
|
|
|
Cache::forget('settings');//Main page settings cache
|
2022-10-04 05:35:46 +02:00
|
|
|
//Clear because they are affected by settings change (sort_on)
|
|
|
|
Cache::forget('all_servers');
|
|
|
|
Cache::forget('all_active_servers');
|
|
|
|
Cache::forget('all_shared');
|
|
|
|
Cache::forget('all_seedboxes');
|
|
|
|
Cache::forget('all_reseller');
|
|
|
|
Cache::forget('all_misc');
|
2022-10-31 01:15:28 +01:00
|
|
|
Cache::forget('all_domains');
|
2022-10-04 05:35:46 +02:00
|
|
|
|
|
|
|
Settings::setSettingsToSession(Settings::getSettings());
|
2022-03-05 16:58:25 +01:00
|
|
|
|
2022-03-05 16:02:12 +01:00
|
|
|
return redirect()->route('settings.index')
|
|
|
|
->with('success', 'Settings Updated Successfully.');
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|