ProfileUpdateRequest.php 743 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace App\Http\Requests;
  3. use App\Models\User;
  4. use Illuminate\Foundation\Http\FormRequest;
  5. use Illuminate\Validation\Rule;
  6. class ProfileUpdateRequest extends FormRequest
  7. {
  8. /**
  9. * Get the validation rules that apply to the request.
  10. *
  11. * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
  12. */
  13. public function rules(): array
  14. {
  15. return [
  16. 'name' => ['required', 'string', 'max:255'],
  17. 'email' => [
  18. 'required',
  19. 'string',
  20. 'lowercase',
  21. 'email',
  22. 'max:255',
  23. Rule::unique(User::class)->ignore($this->user()->id),
  24. ],
  25. ];
  26. }
  27. }