<?php

namespace App\Http\Requests;


use App\Rules\PasswordValidationRule;

class ManageClientRequest extends BaseRequest
{

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {

        return [
            'creditreport.first_name' => 'required',
            'creditreport.last_name' => 'required',
            'creditreport.birth_date' => 'required',
            'creditreport.street_no' => 'required|regex:'.$this->script_validation_rule,
            'creditreport.street_name' => 'required|regex:'.$this->script_validation_rule,
            'creditreport.city' => 'required|regex:'.$this->script_validation_rule,
            'creditreport.state' => 'required|regex:'.$this->script_validation_rule,
            'creditreport.zip_code' => 'required|regex:'.$this->script_validation_rule,
            'creditreport.phone' => 'required|regex:'.$this->script_validation_rule,
            'uploadmedia.identification' =>  'file|max:'.config('constant.MAX_FILE_SIZE'),
            'uploadmedia.ssn' =>  'file|max:'.config('constant.MAX_FILE_SIZE'),
            'uploadmedia.state_photo_id' => 'file|max:'.config('constant.MAX_FILE_SIZE'),
            'uploadmedia.mail_doc' => 'file|max:'.config('constant.MAX_FILE_SIZE'),
            'creditreport.credit_report_company_type' => 'required',
            'creditreport.ssn' => ['required','min:4','max:4'],
            'creditreport.password' => ['required','min:8',new PasswordValidationRule()]
        ];
    }

    public function messages()
    {
        $file_size_message = "Maximum file size to upload is ".sizeFilter(config('constant.MAX_FILE_SIZE')). " . If you are uploading a file, try to make it under ".sizeFilter(config('constant.MAX_FILE_SIZE')).".";
        return [
            'uploadmedia.identification.max' => 'Identification: '.$file_size_message,
            'uploadmedia.ssn.max' => 'SSN: '.$file_size_message,
            'uploadmedia.state_photo_id.max' => 'State Photo: '.$file_size_message,
            'uploadmedia.mail_doc.max' => 'Other Doc: '.$file_size_message,
            'creditreport.password.min' => 'Password mast be 8 characters.',
            'creditreport.password' => 'Password is required.',
            'creditreport.ssn.min' => 'Please enter last 4 digit of your ssn.',
            'creditreport.ssn.max' => 'Please enter last 4 digit of your ssn.',
        ];
    }
}
