AI store generator for ecommerce, Malaysia first. Laravel 13 + React + TypeScript.
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

ProfileValidationRules.php 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace App\Concerns;
  3. use App\Models\User;
  4. use Illuminate\Contracts\Validation\ValidationRule;
  5. use Illuminate\Validation\Rule;
  6. use Illuminate\Validation\Rules\Unique;
  7. trait ProfileValidationRules
  8. {
  9. /**
  10. * Get the validation rules used to validate user profiles.
  11. *
  12. * @return array<string, array<int, Unique|ValidationRule|array<mixed>|string>>
  13. */
  14. protected function profileRules(?int $userId = null): array
  15. {
  16. return [
  17. 'name' => $this->nameRules(),
  18. 'email' => $this->emailRules($userId),
  19. ];
  20. }
  21. /**
  22. * Get the validation rules used to validate user names.
  23. *
  24. * @return array<int, Unique|ValidationRule|array<mixed>|string>
  25. */
  26. protected function nameRules(): array
  27. {
  28. return ['required', 'string', 'max:255'];
  29. }
  30. /**
  31. * Get the validation rules used to validate user emails.
  32. *
  33. * @return array<int, Unique|ValidationRule|array<mixed>|string>
  34. */
  35. protected function emailRules(?int $userId = null): array
  36. {
  37. return [
  38. 'required',
  39. 'string',
  40. 'email',
  41. 'max:255',
  42. $userId === null
  43. ? Rule::unique(User::class)
  44. : Rule::unique(User::class)->ignore($userId),
  45. ];
  46. }
  47. }