<?php

namespace App\Http\Middleware;

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

class CheckAppVersion
{
    public function handle(Request $request, Closure $next): Response
    {
        $currentVersion = config('app.version');

        if (session('app_version') !== $currentVersion) {
            session(['show_update_banner' => true]);
            session(['app_version' => $currentVersion]);
        }

        return $next($request);
    }
}
