<?php

declare(strict_types=1);

namespace App\Policies;

use App\Models\SupportTicket;
use App\Models\User;

class SupportTicketPolicy
{
    public function viewAny(User $user): bool
    {
        return true;
    }

    public function view(User $user, SupportTicket $supportTicket): bool
    {
        return $user->hasRole('admin') || $supportTicket->user_id === $user->id;
    }

    public function create(User $user): bool
    {
        return true;
    }

    public function reply(User $user, SupportTicket $supportTicket): bool
    {
        return $user->hasRole('admin') || $supportTicket->user_id === $user->id;
    }

    public function close(User $user, SupportTicket $supportTicket): bool
    {
        return $user->hasRole('admin') || $supportTicket->user_id === $user->id;
    }
}
