mirror of
https://github.com/Deathgarden-Rebirth/Deathgarden_Rebirth-Rewrite.git
synced 2026-09-09 19:55:22 -05:00
Added new Admin Tool page to manage the different versions we need to control. These are:
- launcher version (updating launcher) - game version - content version (for catalog) - catalog version Also added checks that when the wrong content version you dont get a catalog until you update tha game. And added another check when queuing when using the wrong game version you dont get queued. (so that hunters on the wrong version cannot block the matchmaking)
This commit is contained in:
41
dist/app/Models/AbstractFileBasedModel.php
vendored
Normal file
41
dist/app/Models/AbstractFileBasedModel.php
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Filesystem\FilesystemAdapter;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
abstract class AbstractFileBasedModel
|
||||
{
|
||||
const FILE_NAME = 'file-name';
|
||||
|
||||
const CACHE_DURATION = 3600;
|
||||
|
||||
protected static ?FilesystemAdapter $disk = null;
|
||||
|
||||
public function save(): bool|string {
|
||||
$success = static::getDisk()->put(static::FILE_NAME, serialize($this));
|
||||
|
||||
if($success === true)
|
||||
Cache::forget(static::FILE_NAME);
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
public static function get(): ?static {
|
||||
return Cache::remember(
|
||||
static::FILE_NAME,
|
||||
static::CACHE_DURATION,
|
||||
function () {
|
||||
$data = static::getDisk()->get(static::FILE_NAME);
|
||||
|
||||
return $data === null ? null : unserialize($data);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
protected static function getDisk(): FilesystemAdapter {
|
||||
return static::$disk ?? static::$disk = Storage::disk('local');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user