select box

This commit is contained in:
antv
2026-07-13 16:28:44 +07:00
parent f0a25b840c
commit 47a8892623
24 changed files with 889 additions and 302 deletions
@@ -29,6 +29,8 @@ class UpdateUserRequest extends FormRequest
*/
public function rules(): array
{
$msnv = $this->route('msnv');
return [
'card' => 'nullable|integer|min:0',
'num_card' => 'nullable|integer|min:1',
@@ -36,6 +38,12 @@ class UpdateUserRequest extends FormRequest
'status' => 'nullable|in:' . config('constants.STATUS_INACTIVE') . ',' . config('constants.STATUS_ACTIVE'),
'flag_send' => 'nullable|in:0,1',
'first_login' => 'nullable|in:' . config('constants.FIRST_LOGIN_FALSE') . ',' . config('constants.FIRST_LOGIN_TRUE'),
// Editable basic info
'name' => 'sometimes|required|string|max:255',
'mail' => 'sometimes|required|email|unique:user,mail,' . $msnv . ',msnv',
'departments' => 'sometimes|required|string|in:' . implode(',', config('constants.DEPARTMENTS')),
'avatar' => 'nullable|image|max:2048',
];
}
}
@@ -20,8 +20,35 @@ class UpdateProfileRequest extends FormRequest
public function rules(): array
{
return [
'avatar' => 'nullable|image|max:2048', // 2MB max
'new_password' => 'nullable|min:6|confirmed',
'name' => 'required|string|max:255',
'avatar' => 'nullable|image|max:2048', // 2MB max
'current_password' => [
'nullable',
'required_with:new_password',
function ($attribute, $value, $fail) {
if ($value && md5($value) !== auth()->user()->pass) {
$fail('Mật khẩu hiện tại không chính xác.');
}
},
],
'new_password' => 'nullable|min:6|confirmed|different:current_password',
];
}
/**
* Get the error messages for the defined validation rules.
*/
public function messages(): array
{
return [
'name.required' => 'Họ và tên không được để trống.',
'name.string' => 'Họ và tên phải là chuỗi ký tự.',
'name.max' => 'Họ và tên không được vượt quá 255 ký tự.',
'avatar.image' => 'Ảnh đại diện phải là tệp ảnh.',
'avatar.max' => 'Ảnh đại diện không được vượt quá 2MB.',
'new_password.min' => 'Mật khẩu mới phải có ít nhất 6 ký tự.',
'new_password.confirmed' => 'Mật khẩu xác nhận không trùng khớp.',
'new_password.different' => 'Mật khẩu mới phải khác mật khẩu hiện tại.',
];
}
}