You've already forked Atomcms-edit
50 lines
1.1 KiB
PHP
Executable File
50 lines
1.1 KiB
PHP
Executable File
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Services;
|
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Schema;
|
|
use Throwable;
|
|
|
|
readonly class InstallationService
|
|
{
|
|
private const string CACHE_KEY = 'app_installed';
|
|
|
|
public static function isComplete(): bool
|
|
{
|
|
if (Cache::has(self::CACHE_KEY)) {
|
|
return true;
|
|
}
|
|
|
|
try {
|
|
if (! Schema::hasTable('website_installation')) {
|
|
return false;
|
|
}
|
|
|
|
$installation = DB::table('website_installation')->first();
|
|
$isComplete = $installation !== null && (bool) $installation->completed;
|
|
|
|
if ($isComplete) {
|
|
Cache::rememberForever(self::CACHE_KEY, fn (): bool => true);
|
|
}
|
|
|
|
return $isComplete;
|
|
} catch (Throwable) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public static function setComplete(): void
|
|
{
|
|
Cache::rememberForever(self::CACHE_KEY, fn (): bool => true);
|
|
}
|
|
|
|
public static function clearCache(): void
|
|
{
|
|
Cache::forget(self::CACHE_KEY);
|
|
}
|
|
}
|