<?php

namespace App\Http\Requests;

use App\Http\Requests\Request;

class ViewLangRequest 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 = [
            'name'    => 'required',
            'summary' => 'required',
        ];

        $newRules = self::requestArray($this->input('description'), [], 'text');

        return $rules + $newRules;
    }

    public function messages()
    {
        $message = [
            'name.required'     => '标签名不能为空',
            'summary.required'  => '备注不能为空',
        ];

        $newMessages = self::requestArray($this->input('description'), ['text' => '内容'], 'text');

        return $message + $newMessages;
    }
}
