PaymentSplitRequest.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace App\Http\Requests;
  3. use Illuminate\Foundation\Http\FormRequest;
  4. class PaymentSplitRequest extends FormRequest
  5. {
  6. public function authorize(): bool
  7. {
  8. return true;
  9. }
  10. public function rules(): array
  11. {
  12. $rules = [
  13. 'payment_id' => ['sometimes', 'integer', 'exists:payments,id'],
  14. 'provider_id' => ['sometimes', 'integer', 'exists:providers,id'],
  15. 'gateway_provider' => ['sometimes', 'string', 'max:255'],
  16. 'gateway_transfer_target_reference' => ['nullable', 'string', 'max:255'],
  17. 'gateway_transfer_target_label' => ['nullable', 'string', 'max:255'],
  18. 'status' => ['sometimes', 'in:pending,processing,transferred,failed,cancelled'],
  19. 'gross_amount' => ['sometimes', 'numeric', 'min:0'],
  20. 'gateway_fee_amount' => ['sometimes', 'numeric', 'min:0'],
  21. 'net_amount' => ['sometimes', 'numeric', 'min:0'],
  22. 'transferred_at' => ['nullable', 'date'],
  23. 'metadata' => ['nullable', 'array'],
  24. ];
  25. if ($this->isMethod('POST')) {
  26. $rules['payment_id'] = ['required', 'integer', 'exists:payments,id'];
  27. $rules['provider_id'] = ['required', 'integer', 'exists:providers,id'];
  28. $rules['gross_amount'] = ['required', 'numeric', 'min:0'];
  29. $rules['net_amount'] = ['required', 'numeric', 'min:0'];
  30. }
  31. return $rules;
  32. }
  33. }