<?php

namespace App\Http\Requests;

use App\Http\Requests\Request;

class DownloadRequest extends Request
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $rules = [
            'pid' => 'required',
            'filepath' => 'required',
            'description.' . config('setting.lang') . '.title' => 'required',
        ];

        if (config('managerLang') != config('setting.lang')) {
            unset($rules['description.' . config('setting.lang') . '.title']);
        }

        return $rules;
    }

    public function messages()
    {
        $message = [
            'pid.required' => '请选择分类',
            'filepath.required' => '请上传附件',
            'description.' . config('setting.lang') . '.title.required' => '下载名称不能为空',
        ];

        return $message;
    }


}
