Files
dph-tycg-event/app/Http/Requests/EventHealthAllowanceRequest.php

59 lines
1.6 KiB
PHP

<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class EventHealthAllowanceRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function rules()
{
return [
'hospital_name' => 'required|min:2',
'name' => 'required|min:1|max:128',
'twid' => 'required|isNI',
'phone' => 'required|phone:TW',
'email' => 'required|email',
'address' => ['required','regex:/^(\d{3})\s+([\p{Han}]{2,4}[縣市])\s+([\p{Han}]{2,4}[鎮鄉市區])\s+([\p{Han}]+[里村])\s+(.+)$/u'],
'check_reson' => 'required_if:check_state,3',
];
}
/**
* Get the validation attributes that apply to the request.
*
* @return array
*/
public function attributes()
{
return [
'hospital_name' => '就醫院所',
'name' => '姓名',
'twid' => '身份證字號',
'phone' => '行動電話',
'email' => '電子信箱',
'address' => '收件地址'
];
}
/**
* Get the validation messages that apply to the request.
*
* @return array
*/
public function messages()
{
return [
'twid.is_n_i' => '身份證字號驗證有誤',
'phone.phone' => '行動電話驗證有誤',
'address.regex' => '收件地址格式有誤,請填寫完整。',
'check_reson.required_if' => '當審核狀態為「未通過」時,必需填寫「審核回應」欄位'
];
}
}