<?php

namespace App\Modules\Pilkades\Policies;

use App\Models\User;
use App\Modules\Pilkades\Models\Desa;

class DesaPolicy
{
    public function viewAny(User $user): bool
    {
        return $user->isSuperAdmin() || $user->isAdminDesa();
    }

    public function view(User $user, Desa $desa): bool
    {
        return $user->isSuperAdmin() || ($user->isAdminDesa() && $user->desa_id === $desa->id);
    }

    public function create(User $user): bool
    {
        return $user->isSuperAdmin();
    }

    public function update(User $user, Desa $desa): bool
    {
        return $user->isSuperAdmin() || ($user->isAdminDesa() && $user->desa_id === $desa->id);
    }

    public function delete(User $user, Desa $desa): bool
    {
        return $user->isSuperAdmin();
    }
}
