<?php

namespace App\Modules\Pilkades\Services;

use App\Modules\Pilkades\Models\Desa;
use Illuminate\Support\Facades\Cache;

class LandingPageCacheService
{
    public function key(string $kabupatenSlug, string $kecamatanSlug, string $desaSlug): string
    {
        return "landing:{$kabupatenSlug}:{$kecamatanSlug}:{$desaSlug}";
    }

    public function forget(Desa $desa): void
    {
        $desa->loadMissing('kecamatan.kabupaten');

        Cache::forget($this->key(
            $desa->kecamatan->kabupaten->slug,
            $desa->kecamatan->slug,
            $desa->slug,
        ));
    }
}
