You've already forked Atomcms-edit
Initial commit
This commit is contained in:
Executable
+49
@@ -0,0 +1,49 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user