diff --git a/app/Http/Requests/PrintStatementRequest.php b/app/Http/Requests/PrintStatementRequest.php index 601e47d..30b704c 100644 --- a/app/Http/Requests/PrintStatementRequest.php +++ b/app/Http/Requests/PrintStatementRequest.php @@ -40,8 +40,19 @@ class PrintStatementRequest extends FormRequest 'is_period_range' => ['sometimes', 'boolean'], 'email' => ['nullable', 'email'], 'email_sent_at' => ['nullable', 'timestamp'], - 'request_type' => ['sometimes', 'string', 'in:single_account,branch,all_branches'], + 'request_type' => ['sometimes', 'string', 'in:single_account,branch,all_branches,multi_account'], 'batch_id' => ['nullable', 'string'], + // Password wajib diisi jika request_type diisi + 'password' => [ + function ($attribute, $value, $fail) { + $requestType = $this->input('request_type'); + + // Jika request_type diisi, maka password wajib diisi + if (!empty($requestType) && empty($value)) { + $fail('Password is required when request type is specified.'); + } + } + ], 'period_from' => [ 'required', 'string', @@ -108,7 +119,8 @@ class PrintStatementRequest extends FormRequest 'period_to.required' => 'End period is required for period range', 'period_to.regex' => 'End period must be in YYYYMM format', 'period_to.gte' => 'End period must be after or equal to start period', - 'request_type.in' => 'Request type must be single_account, branch, or all_branches', + 'request_type.in' => 'Request type must be single_account, branch, all_branches, or multi_account', + 'password.required' => 'Password is required when request type is specified', ]; }