37 lines
1.0 KiB
PHP
37 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Ktm;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class RegisterKpApplicantRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return $this->user()?->hasRole('KTM') === true;
|
|
}
|
|
|
|
protected function prepareForValidation(): void
|
|
{
|
|
$this->merge([
|
|
'ic_number' => preg_replace('/\D+/', '', (string) $this->input('ic_number')),
|
|
'phone_number' => trim((string) $this->input('phone_number')),
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'ktm_assignment_id' => ['required', 'integer', 'exists:staff_assignments,id'],
|
|
'name' => ['required', 'string', 'max:255'],
|
|
'ic_number' => ['required', 'digits:12'],
|
|
'phone_number' => ['required', 'string', 'max:30'],
|
|
'email' => ['required', 'email', 'max:255'],
|
|
'address' => ['nullable', 'string', 'max:1000'],
|
|
];
|
|
}
|
|
}
|