<?php

namespace App\Policies;

use App\Models\PlayerRecord;
use App\Models\User;

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

    public function view(User $user, PlayerRecord $record): bool
    {
        return $user->isAdmin()
            || $record->playerProfile?->user_id === $user->id;
    }

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

    public function delete(User $user, PlayerRecord $record): bool
    {
        return $user->isAdmin()
            || $record->playerProfile?->user_id === $user->id;
    }
}
