<?php

namespace App\Policies;

use App\Models\User;
use App\Models\WarningLetter;

class WarningLetterPolicy
{
    public function viewAny(User $user): bool
    {
        return $user->isSuperAdmin() || $user->isAdminTU() || $user->hasRole('kepala_sekolah');
    }

    public function view(User $user, WarningLetter $warningLetter): bool
    {
        return $user->isSuperAdmin() || $user->isAdminTU() || $user->hasRole('kepala_sekolah') || $user->id === $warningLetter->user_id;
    }

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

    public function update(User $user, WarningLetter $warningLetter): bool
    {
        return $user->isSuperAdmin() || $user->isAdminTU();
    }

    public function delete(User $user, WarningLetter $warningLetter): bool
    {
        return $user->isSuperAdmin() || $user->isAdminTU();
    }
}
