<?php

namespace App\Policies;

use App\Models\PlayerVideo;
use App\Models\User;

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

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

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

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