ProviderPaymentMethodRequest.php 1.3 KB

1234567891011121314151617181920212223242526272829
  1. <?php
  2. namespace App\Http\Requests;
  3. use App\Enums\AccountTypeEnum;
  4. use App\Enums\BankAccountTypeEnum;
  5. use Illuminate\Foundation\Http\FormRequest;
  6. use Illuminate\Validation\Rule;
  7. class ProviderPaymentMethodRequest extends FormRequest
  8. {
  9. public function authorize(): bool
  10. {
  11. return true;
  12. }
  13. public function rules(): array
  14. {
  15. return [
  16. 'provider_id' => ['required', 'exists:providers,id'],
  17. 'account_type' => ['required', Rule::in([AccountTypeEnum::PIX->value, AccountTypeEnum::BANK_ACCOUNT->value])],
  18. 'pix_key' => ['nullable', 'string', 'max:255', Rule::requiredIf($this->account_type === AccountTypeEnum::PIX->value)],
  19. 'bank_account_type' => ['nullable', Rule::in([BankAccountTypeEnum::CHECKING->value, BankAccountTypeEnum::SAVINGS->value]), Rule::requiredIf($this->account_type === AccountTypeEnum::BANK_ACCOUNT->value)],
  20. 'agency' => ['nullable', 'string', 'max:255', Rule::requiredIf($this->account_type === AccountTypeEnum::BANK_ACCOUNT->value)],
  21. 'account' => ['nullable', 'string', 'max:255', Rule::requiredIf($this->account_type === AccountTypeEnum::BANK_ACCOUNT->value)],
  22. 'digit' => ['nullable', 'string', 'max:255', Rule::requiredIf($this->account_type === AccountTypeEnum::BANK_ACCOUNT->value)],
  23. ];
  24. }
  25. }