mirror of
https://github.com/Deathgarden-Rebirth/Deathgarden_Rebirth-Rewrite.git
synced 2026-04-30 12:06:49 -05:00
- 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)
41 lines
1.0 KiB
PHP
41 lines
1.0 KiB
PHP
<?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');
|
|
}
|
|
} |