<?php

namespace App\Http\Requests\Article;

use App\Http\Requests\Request;

class ArticleRequest 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()
    {
        if(!$this->ajax()) {
            return [];
        }
        return [
            'site_id' => 'required',
            'translator_id' => 'nullable',
            'title' => 'required',
            'content' => 'nullable',
            'thumb' => 'nullable',
            'translate_title' => 'nullable',
            'translate_content' => 'nullable',
            'group' => 'required|array'
        ];
    }

    public function attributes()
    {
        return [
            'site_id' => '项目信息',
            'translator_id' => '翻译人员',
            'title' => '标题',
            'thumb' => '缩略图',
            'translate_title' => '英文标题',
            'translate_content' => '英文正文',
            'group' => '中文关键词,英文关键词,锚点链接'

        ];
    }
}