<?php
/**
 * Created by PhpStorm.
 * User: UNTREF
 * Date: 19/10/2017
 * Time: 12:31 PM
 */

namespace App\Http\Requests;


class CreateLogout
{
    /**
     * 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(Request $request)
    {

        if ($request->deleteemail == '') {
            return [
                'profile_id' => ['required'],
                'name' => ['required', 'regex:/(([a-zA-Z]+)\s+\1$|[a-zA-Z]+$)/u'],
                'surname' => ['required', 'regex:/(([a-zA-Z]+)\s+\1$|[a-zA-Z]+$)/u'],
                'personalemail' => ['required', 'email']
            ];
        } else {
            return [
                'profile_id' => ['required']
            ];
        }
    }

    public function messages()
    {
        return [
            'profile_id.required' => ' Seleccione Perfil relacionado a la tarea.',
            'name.required' => 'El campo Nombre/s es requerido.',
            'name.regex' => 'El formato del nombre es inválido',
            'surname.required' => 'El campo Apellido/s es requerido.',
            '.regex' => 'El formato del Apellido es inválido',
            'personalsurnameemail.required' => 'El campo Email Personal es requerido.',
            'personalemail.email' => 'El campo Email Personal debe ser un email válido. '
        ];

    }

}