<?php

namespace App\Http\Requests;

use App\Http\Requests\Request;

class NavRequest 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 = [
            'linkurl' => 'required_if:types,1 | required_if:content_model,""',
            'description.' . config('setting.lang') . '.cname' => 'required',
        ];

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

        return $rules;
    }

    public function messages()
    {
        $message = [
            'linkurl.required_if' => '栏目链接不能为空',
            'description.' . config('setting.lang') . '.cname.required' => '导航名称不能为空',
        ];

        return $message;

    }
}
