<?php

namespace Signteer\Web\Install\Middleware;

use Plainwork\Http\Request;
use Plainwork\Http\Redirect;
use Plainwork\Database\Migrator;

class CheckInstallMiddleware
{
    public $migrator = Migrator::class;

    public function __invoke(Request $request, callable $next)
    {
        $this->migrator->up();
        set_transient('signteer_flush_rewrite_rules', true);

        return $next($request);

        // if ('install' === $request->getPath()) {
            // return $next($request);
        // }

        // $installed = $this->migrator->isInstalled();
        // if (!$installed) {
            // return new Redirect('install');
        // } else {
            // $this->migrator->up();
        // }

        // return $next($request);
    }
}
