<?php

namespace LaraBB\Torrent\UI\Web\Requests;

use Illuminate\Foundation\Http\FormRequest;

/**
 *
 */
class DownloadRequest extends FormRequest
{
    /**
     * @return mixed
     */
    public function authorize(): mixed
    {
        return $this->user()->isInGroup(['Member']);
    }

    /**
     * @return string[]
     */
    public function rules(): array
    {
        return [
            'uuid' => 'required|exists:users_torrents,uuid'
        ];
    }

    /**
     * @return array
     */
    public function messages(): array
    {
        return [
            'uuid.required' => trans('Please provide the UUID of the torrent you want to download.'),
            'uuid.exists'   => trans('The torrent file you want to download doesn\'t exists.')
        ];
    }

    /**
     * @param $keys
     * @return array
     */
    public function all($keys = null): array
    {
        $data         = parent::all($keys);
        $data['uuid'] = $this->route('uuid');

        return $data;
    }
}
