<?php

namespace App\Http\Requests;

use App\Http\Requests\Request;

class CateRequest 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 = [
            'description.' . config('setting.lang') . '.cname' => 'required'
        ];

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

        return $rules;
    }

    public function messages()
    {
        return [
            'description.' . config('setting.lang') . '.cname.required' => '分类名称不能为空',
        ];

    }
}
