<?php

namespace App\Http\View\Composers;

use App\Core\Services\Update\UpdateChecker;
use Illuminate\View\View;

class UpdateNotificationComposer
{
    public function __construct(
        private UpdateChecker $updateChecker
    ) {}

    /**
     * Bind data to the view.
     */
    public function compose(View $view): void
    {
        $hasUpdate = false;

        // Only check if user has license access
        if ($this->updateChecker->hasUpdateAccess()) {
            $latestUpdate = $this->updateChecker->getLatestUpdate();
            $hasUpdate = $latestUpdate !== null;
        }

        $view->with('hasUpdateAvailable', $hasUpdate);
    }
}
