<?php

namespace App\Policies;

use App\Models\EventRegistration;
use App\Models\User;

class EventRegistrationPolicy
{
    public function view(User $user, EventRegistration $registration): bool
    {
        return $user->isAdmin() || $registration->user_id === $user->id;
    }

    public function create(User $user): bool
    {
        return $user->playerProfile !== null;
    }

    public function cancel(User $user, EventRegistration $registration): bool
    {
        return $registration->user_id === $user->id
            && $registration->status->isActive();
    }

    public function review(User $user, EventRegistration $registration): bool
    {
        return $user->isAdmin();
    }
}
