| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- <?php
- namespace App\Services;
- use App\Models\User;
- class AssociateValidationService
- {
- public function validate(array $data): ?User
- {
- return User::query()
- ->where(function ($query) use ($data) {
- if (!empty($data['cpf'])) {
- $query->orWhere(
- 'cpf',
- $data['cpf']
- );
- }
- if (!empty($data['registration'])) {
- $query->orWhere(
- 'registration',
- $data['registration']
- );
- }
- if (!empty($data['name'])) {
- $query->orWhere(
- 'name',
- 'like',
- '%' . $data['name'] . '%'
- );
- }
- })
-
- ->first();
- }
- }
|