59 lines
2.1 KiB
PHP
59 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Employee;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class ProfileUpdateRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'name' => ['required', 'string', 'max:255'],
|
|
'gender' => ['nullable', 'string'],
|
|
'birth_date' => ['nullable', 'date'],
|
|
'phone' => ['nullable', 'regex:/^(\+?)(\d{1,3})?([-.\s]?)(\(\d{1,4}\))?(?:[-.\s]?(\d{1,5}))?([-.\s]?(\d{1,5}))?([-.\s]?(\d{1,5}))?$/', 'max:13'],
|
|
'address' => ['nullable', 'string'],
|
|
'picture' => ['nullable', 'image', 'mimes:jpeg,jpg,png', 'max:1024'],
|
|
|
|
// ? Employee
|
|
'nip' => ['nullable', 'string', 'max:25'],
|
|
'position' => ['nullable', 'string', 'max:50'],
|
|
];
|
|
}
|
|
|
|
public function messages()
|
|
{
|
|
return [
|
|
'name.required' => 'Nama harus diisi',
|
|
'name.string' => 'Nama harus berupa teks',
|
|
'name.max' => 'Nama maksimal 255 karakter',
|
|
'gender.string' => 'Jenis kelamin harus berupa teks',
|
|
'birth_date.date' => 'Tanggal lahir harus berupa format tanggal',
|
|
'phone.regex' => 'Nomor telepon tidak valid',
|
|
'phone.max' => 'Nomor telepon maksimal 13 karakter',
|
|
'address.string' => 'Alamat harus berupa teks',
|
|
'picture.image' => 'Foto harus berupa gambar',
|
|
'picture.mimes' => 'Foto harus berformat jpeg, jpg, atau png',
|
|
'picture.max' => 'Ukuran foto maksimal 1 MB',
|
|
'nip.string' => 'NIP harus berupa teks',
|
|
'nip.max' => 'NIP maksimal 25 karakter',
|
|
'position.string' => 'Jabatan harus berupa teks',
|
|
'position.max' => 'Jabatan maksimal 50 karakter',
|
|
];
|
|
}
|
|
}
|