<?php

namespace App\Http\Requests;

use App\Http\Requests\Request;

class NewsRequest 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',
            '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' => '请选择分类',
            'description.' . config('setting.lang') . '.title.required' => '新闻名称不能为空',
        ];

        return $message;
    }
}
