<?php

namespace App\Http\Controllers\Store;

use App\Http\Controllers\Controller;
use App\Models\Contract;
use App\Services\LocaleOverrideService;
use Illuminate\Http\Request;

class PublicContractController extends Controller
{
    public function show(string $slug, Request $request, LocaleOverrideService $localeService)
    {
        $found = Contract::findBySlugInAnyLocale($slug);
        if (! $found) {
            abort(404);
        }

        $localeService->resolveFromSlug($found['matched_locale'], $request);

        return view('store.legal.contract', ['contract' => $found['contract']]);
    }
}
