diff --git a/.gitignore b/.gitignore index eb160f7d..9dd097b7 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ /storage/*.key /vendor /storage/credit_deduction_log +storage/debugbar .env .env.testing .env.backup diff --git a/app/Http/Controllers/Admin/OverViewController.php b/app/Http/Controllers/Admin/OverViewController.php index dcff344c..1fa022ec 100644 --- a/app/Http/Controllers/Admin/OverViewController.php +++ b/app/Http/Controllers/Admin/OverViewController.php @@ -50,7 +50,7 @@ class OverViewController extends Controller 'syncLastUpdate' => $syncLastUpdate ]); } - + /** * @description Sync locations,nodes,nests,eggs with the linked pterodactyl panel */ diff --git a/app/Models/Configuration.php b/app/Models/Configuration.php index 2f5aa6f7..a07846f2 100644 --- a/app/Models/Configuration.php +++ b/app/Models/Configuration.php @@ -4,11 +4,14 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Illuminate\Support\Facades\Cache; class Configuration extends Model { use HasFactory; + public const CACHE_TAG = 'configuration'; + public $primaryKey = 'key'; public $incrementing = false; @@ -21,14 +24,25 @@ class Configuration extends Model 'type', ]; + public static function boot() + { + parent::boot(); + + static::updated(function (Configuration $configuration) { + Cache::forget(self::CACHE_TAG .':'. $configuration->key); + }); + } + /** * @param string $key * @param $default * @return mixed */ - public static function getValueByKey(string $key , $default = null) + public static function getValueByKey(string $key, $default = null) { - $configuration = self::find($key); - return $configuration ? $configuration->value : $default; + return Cache::rememberForever(self::CACHE_TAG .':'. $key, function () use ($default, $key) { + $configuration = self::find($key); + return $configuration ? $configuration->value : $default; + }); } } diff --git a/resources/views/layouts/main.blade.php b/resources/views/layouts/main.blade.php index 266fc9db..167863e6 100644 --- a/resources/views/layouts/main.blade.php +++ b/resources/views/layouts/main.blade.php @@ -187,7 +187,42 @@ @endif @if(Auth::user()->role == 'admin') - + + + + + + + + + + + + --}} - - - - + - - - - - -