HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: /home/xedaptot/hi.naniguide.com/app/Http/Middleware/EnsureInstalled.php
<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;

class EnsureInstalled
{
    public function handle(Request $request, Closure $next): Response
    {
        if ($this->isInstalled()) {
            return $next($request);
        }

        $path = ltrim($request->path(), '/');

        if (
            $path === 'install'
            || str_starts_with($path, 'install/')
            || str_starts_with($path, 'build/')
            || str_starts_with($path, 'cron/')
            || str_starts_with($path, 'storage/')
            || str_starts_with($path, 'public/')
            || $path === 'up'
        ) {
            return $next($request);
        }

        return redirect()->route('install.welcome');
    }

    private function isInstalled(): bool
    {
        return (bool) config('mailpurse.skip_install_wizard', false)
            || is_file($this->installedPath());
    }

    private function installedPath(): string
    {
        return storage_path('app/private/installed.json');
    }
}