Added setSettingsSession function
Added setSettingsSession function Moved get settings from Home controller into settings model
This commit is contained in:
parent
fb22a50ff6
commit
24a583f3fd
|
@ -6,6 +6,7 @@ use App\Models\DNS;
|
||||||
use App\Models\Home;
|
use App\Models\Home;
|
||||||
use App\Models\Labels;
|
use App\Models\Labels;
|
||||||
use App\Models\Pricing;
|
use App\Models\Pricing;
|
||||||
|
use App\Models\Settings;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Support\Facades\Cache;
|
use Illuminate\Support\Facades\Cache;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
@ -36,26 +37,9 @@ class HomeController extends Controller
|
||||||
|
|
||||||
$recently_added = Home::recentlyAdded();
|
$recently_added = Home::recentlyAdded();
|
||||||
|
|
||||||
$settings = Cache::remember('settings', now()->addMinute(1), function () {
|
$settings = Settings::getSettings();
|
||||||
return DB::table('settings')
|
|
||||||
->where('id', '=', 1)
|
|
||||||
->get();
|
|
||||||
});
|
|
||||||
|
|
||||||
Session::put('dark_mode', $settings[0]->dark_mode ?? 0);
|
Settings::setSettingsToSession($settings);
|
||||||
Session::put('timer_version_footer', $settings[0]->show_versions_footer ?? 1);
|
|
||||||
Session::put('show_servers_public', $settings[0]->show_servers_public ?? 0);
|
|
||||||
Session::put('show_server_value_ip', $settings[0]->show_server_value_ip ?? 0);
|
|
||||||
Session::put('show_server_value_hostname', $settings[0]->show_server_value_hostname ?? 0);
|
|
||||||
Session::put('show_server_value_price', $settings[0]->show_server_value_price ?? 0);
|
|
||||||
Session::put('show_server_value_yabs', $settings[0]->show_server_value_yabs ?? 0);
|
|
||||||
Session::put('show_server_value_provider', $settings[0]->show_server_value_provider ?? 0);
|
|
||||||
Session::put('show_server_value_location', $settings[0]->show_server_value_location ?? 0);
|
|
||||||
Session::put('default_currency', $settings[0]->default_currency ?? 'USD');
|
|
||||||
Session::put('default_server_os', $settings[0]->default_server_os ?? 1);
|
|
||||||
Session::put('due_soon_amount', $settings[0]->due_soon_amount ?? 6);
|
|
||||||
Session::put('recently_added_amount', $settings[0]->recently_added_amount ?? 6);
|
|
||||||
Session::save();
|
|
||||||
|
|
||||||
$all_pricing = Pricing::allPricing();
|
$all_pricing = Pricing::allPricing();
|
||||||
|
|
||||||
|
|
|
@ -54,20 +54,7 @@ class SettingsController extends Controller
|
||||||
'recently_added_amount' => $request->recently_added_amount
|
'recently_added_amount' => $request->recently_added_amount
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Session::put('dark_mode', $request->dark_mode ?? 1);
|
Settings::setSettingsToSession($settings);
|
||||||
Session::put('timer_version_footer', $request->show_versions_footer);
|
|
||||||
Session::put('show_servers_public', $request->show_servers_public);
|
|
||||||
Session::put('show_server_value_ip', $request->show_server_value_ip);
|
|
||||||
Session::put('show_server_value_hostname', $request->show_server_value_hostname);
|
|
||||||
Session::put('show_server_value_price', $request->show_server_value_price);
|
|
||||||
Session::put('show_server_value_yabs', $request->show_server_value_yabs);
|
|
||||||
Session::put('show_server_value_provider', $request->show_server_value_provider);
|
|
||||||
Session::put('show_server_value_location', $request->show_server_value_location);
|
|
||||||
Session::put('default_currency', $request->default_currency);
|
|
||||||
Session::put('default_server_os', $request->default_server_os);
|
|
||||||
Session::put('due_soon_amount', $request->due_soon_amount);
|
|
||||||
Session::put('recently_added_amount', $request->recently_added_amount);
|
|
||||||
Session::save();
|
|
||||||
|
|
||||||
Cache::forget('due_soon');//Main page due_soon cache
|
Cache::forget('due_soon');//Main page due_soon cache
|
||||||
Cache::forget('recently_added');//Main page recently_added cache
|
Cache::forget('recently_added');//Main page recently_added cache
|
||||||
|
|
|
@ -4,7 +4,9 @@ namespace App\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Session;
|
||||||
|
|
||||||
class Settings extends Model
|
class Settings extends Model
|
||||||
{
|
{
|
||||||
|
@ -16,8 +18,30 @@ class Settings extends Model
|
||||||
|
|
||||||
public static function getSettings()
|
public static function getSettings()
|
||||||
{
|
{
|
||||||
|
return Cache::remember('settings', now()->addMinute(1), function () {
|
||||||
return DB::table('settings')
|
return DB::table('settings')
|
||||||
->where('id', '=', 1)
|
->where('id', '=', 1)
|
||||||
->get();
|
->get();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function setSettingsToSession($settings): void
|
||||||
|
{
|
||||||
|
Session::put('dark_mode', $settings[0]->dark_mode ?? 0);
|
||||||
|
Session::put('timer_version_footer', $settings[0]->show_versions_footer ?? 1);
|
||||||
|
Session::put('show_servers_public', $settings[0]->show_servers_public ?? 0);
|
||||||
|
Session::put('show_server_value_ip', $settings[0]->show_server_value_ip ?? 0);
|
||||||
|
Session::put('show_server_value_hostname', $settings[0]->show_server_value_hostname ?? 0);
|
||||||
|
Session::put('show_server_value_price', $settings[0]->show_server_value_price ?? 0);
|
||||||
|
Session::put('show_server_value_yabs', $settings[0]->show_server_value_yabs ?? 0);
|
||||||
|
Session::put('show_server_value_provider', $settings[0]->show_server_value_provider ?? 0);
|
||||||
|
Session::put('show_server_value_location', $settings[0]->show_server_value_location ?? 0);
|
||||||
|
Session::put('default_currency', $settings[0]->default_currency ?? 'USD');
|
||||||
|
Session::put('default_server_os', $settings[0]->default_server_os ?? 1);
|
||||||
|
Session::put('due_soon_amount', $settings[0]->due_soon_amount ?? 6);
|
||||||
|
Session::put('recently_added_amount', $settings[0]->recently_added_amount ?? 6);
|
||||||
|
Session::save();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user