2024-03-01 20:34:36 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Services;
|
|
|
|
|
|
|
|
class SettingsService
|
|
|
|
{
|
2024-03-12 23:16:36 +01:00
|
|
|
protected $settings;
|
2024-03-01 20:34:36 +01:00
|
|
|
protected $folks;
|
|
|
|
protected $tags;
|
2024-03-12 23:16:36 +01:00
|
|
|
protected $docs;
|
2024-03-01 20:34:36 +01:00
|
|
|
|
2024-03-12 23:16:36 +01:00
|
|
|
public function __construct(DocService $docService)
|
2024-03-01 20:34:36 +01:00
|
|
|
{
|
2024-03-12 23:16:36 +01:00
|
|
|
$this->folks = json_decode(file_get_contents(env('FOLKS_PATH')), true);
|
|
|
|
$this->docs = $docService;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function loadSettings()
|
|
|
|
{
|
|
|
|
return json_decode(file_get_contents(env('SETTINGS_PATH')), true);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getSettings()
|
|
|
|
{
|
|
|
|
return $this->loadSettings();
|
2024-03-01 20:34:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getGlobal()
|
|
|
|
{
|
2024-03-12 23:16:36 +01:00
|
|
|
$this->settings = $this->loadSettings();
|
|
|
|
return $this->settings['global'];
|
2024-03-01 20:34:36 +01:00
|
|
|
}
|
|
|
|
|
2024-03-14 19:39:43 +01:00
|
|
|
public function getMenu()
|
|
|
|
{
|
|
|
|
$this->settings = $this->loadSettings();
|
|
|
|
return $this->settings['menu'];
|
|
|
|
}
|
|
|
|
|
2024-03-01 20:34:36 +01:00
|
|
|
public function getFolks()
|
|
|
|
{
|
|
|
|
return $this->folks;
|
|
|
|
}
|
2024-03-12 23:16:36 +01:00
|
|
|
|
|
|
|
public function updatePageIndex()
|
|
|
|
{
|
|
|
|
$this->settings = $this->loadSettings();
|
|
|
|
$this->settings['library_stats']['current_index']++;
|
|
|
|
$this->docs->writeSettings($this->settings);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function updateGlobalData($key, $value)
|
|
|
|
{
|
|
|
|
$this->settings = $this->loadSettings();
|
|
|
|
$this->settings['global'][$key] = $data;
|
|
|
|
$this->docs->writeSettings($this->settings);
|
|
|
|
}
|
2024-03-01 20:34:36 +01:00
|
|
|
}
|