2022-03-05 16:02:12 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2022-05-16 07:43:51 +02:00
|
|
|
use Illuminate\Support\Facades\Cache;
|
2022-05-14 17:21:51 +02:00
|
|
|
use Illuminate\Support\Facades\DB;
|
2022-05-16 07:43:51 +02:00
|
|
|
use Illuminate\Support\Facades\Session;
|
2022-03-05 16:02:12 +01:00
|
|
|
|
|
|
|
class Settings extends Model
|
|
|
|
{
|
|
|
|
use HasFactory;
|
|
|
|
|
|
|
|
protected $table = 'settings';
|
2022-03-05 16:58:25 +01:00
|
|
|
|
|
|
|
protected $fillable = ['id', 'show_versions_footer', 'show_servers_public'];
|
2022-05-14 17:21:51 +02:00
|
|
|
|
|
|
|
public static function getSettings()
|
|
|
|
{
|
2022-05-29 08:50:15 +02:00
|
|
|
return Cache::remember('settings', now()->addWeek(1), function () {
|
2022-05-16 07:43:51 +02:00
|
|
|
return DB::table('settings')
|
|
|
|
->where('id', '=', 1)
|
|
|
|
->get();
|
|
|
|
});
|
2022-05-14 17:21:51 +02:00
|
|
|
}
|
2022-05-16 07:43:51 +02:00
|
|
|
|
|
|
|
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);
|
2022-07-20 04:51:45 +02:00
|
|
|
Session::put('save_yabs_as_txt', $settings[0]->save_yabs_as_txt ?? 0);
|
2022-05-16 07:43:51 +02:00
|
|
|
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);
|
2022-05-29 08:46:55 +02:00
|
|
|
Session::put('dashboard_currency', $settings[0]->dashboard_currency ?? 'USD');
|
2022-05-16 07:43:51 +02:00
|
|
|
Session::save();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-03-05 16:02:12 +01:00
|
|
|
}
|