UpdateMeRequest.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace App\Http\Requests;
  3. use Illuminate\Foundation\Http\FormRequest;
  4. use Illuminate\Support\Facades\Auth;
  5. use Illuminate\Validation\Rule;
  6. class UpdateMeRequest extends FormRequest
  7. {
  8. public function authorize(): bool
  9. {
  10. return true;
  11. }
  12. public function rules(): array
  13. {
  14. return [
  15. 'name' => 'sometimes|string|nullable|max:255',
  16. 'email' => [
  17. 'sometimes',
  18. 'email',
  19. 'nullable',
  20. Rule::unique('users', 'email')
  21. ->where('type', Auth::user()?->type?->value)
  22. ->ignore(Auth::id()),
  23. ],
  24. 'phone' => 'sometimes|string|nullable',
  25. 'language' => 'sometimes|string|nullable',
  26. 'document' => 'sometimes|string|nullable',
  27. 'avatar' => 'sometimes|file|image|mimes:jpg,jpeg,png,webp|max:5120',
  28. 'avatar_base64' => 'sometimes|string|nullable',
  29. 'push_notifications_enabled' => 'sometimes|boolean',
  30. ];
  31. }
  32. }