<?php

namespace App\Http\Requests\Videos;

use App\Enums\ProfileVisibility;
use App\Enums\VideoType;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class StorePlayerVideoRequest extends FormRequest
{
    public function authorize(): bool
    {
        return $this->user()?->can('create', \App\Models\PlayerVideo::class) ?? false;
    }

    public function rules(): array
    {
        return [
            'title' => ['required', 'string', 'max:255'],
            'description' => ['nullable', 'string', 'max:5000'],
            'original_url' => ['required', 'string', 'max:2048'],
            'player_game_profile_id' => ['nullable', 'integer', 'exists:player_game_profiles,id'],
            'game_id' => ['nullable', 'integer', 'exists:games,id'],
            'video_type' => ['required', Rule::enum(VideoType::class)],
            'visibility' => ['nullable', Rule::enum(ProfileVisibility::class)],
        ];
    }
}
