<?php

namespace App\Http\Requests;

use App\Http\Requests\Request;

class UserRequest 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()
    {
		switch($this->method())
		{
			case 'POST':
			{
				return [
					'first_name' => 'required',
					'last_name' => 'required',
					'birthday' => 'date',
					'gender' => 'required',
					'email' => 'required|email|unique:users,email',
					'telephone' => 'required|min:3|max:20',
					'local_address' => 'required|max:255',
					
					'nauticaltitle'=> 'max:255',
					'nauticaltitleexpedicion' => 'date',
					'nauticaltitleexpiration' => 'date|after:nauticaltitleexpedicion',
					'sendemail'=>'required',
					'sendsms'=>'required',
					'profile_picture' => 'image',
					'role_id' => 'required|numeric',
					'customer_id' => 'required|numeric',
					'password' => 'required|min:8|confirmed',
					'password_confirmation' => 'required|min:8'
				];
			}
			case 'PATCH':
			{
				return [
					'first_name' => 'required',
					'last_name' => 'required',
					'birthday' => 'required|date',
					'gender' => 'required',
					'email' => 'required|email|unique:users,email,'.$this->get('id'),
					'telephone' => 'required|min:3|max:20',
					'local_address' => 'required|max:255',
					
					'nauticaltitle'=> 'required|max:255',
					'nauticaltitleexpedicion' => 'required|date',
					'nauticaltitleexpiration' => 'required|date|after:nauticaltitleexpedicion',
					'sendemail'=>'required',
					'sendsms'=>'required',
					'profile_picture' => 'image',
					'role_id' => 'required|numeric',
					'customer_id' => 'required|numeric',
					'password' => 'min:8|confirmed',
					'password_confirmation' => 'min:8'
				];
			}
		}
    }
}
