EditDefaultRecipientRequest.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace App\Http\Requests;
  3. use App\Rules\RegisterUniqueRecipient;
  4. use Illuminate\Foundation\Http\FormRequest;
  5. class EditDefaultRecipientRequest extends FormRequest
  6. {
  7. /**
  8. * Determine if the user is authorized to make this request.
  9. *
  10. * @return bool
  11. */
  12. public function authorize()
  13. {
  14. return true;
  15. }
  16. /**
  17. * Get the validation rules that apply to the request.
  18. *
  19. * @return array
  20. */
  21. public function rules()
  22. {
  23. return [
  24. 'email' => [
  25. 'required',
  26. 'email:rfc,dns',
  27. 'max:254',
  28. 'confirmed',
  29. new RegisterUniqueRecipient,
  30. 'not_in:'.$this->user()->email
  31. ]
  32. ];
  33. }
  34. /**
  35. * Get the error messages for the defined validation rules.
  36. *
  37. * @return array
  38. */
  39. public function messages()
  40. {
  41. return [
  42. 'email.not_in' => 'That email is the same as the current one.'
  43. ];
  44. }
  45. }