|
@@ -24,8 +24,15 @@ class UserService
|
|
|
$user->loadMissing('partnerAgreement');
|
|
$user->loadMissing('partnerAgreement');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- return $user->load(['position', 'sector'])
|
|
|
|
|
- ->loadCount(['notificationSends as unread_notifications_count' => fn($q) => $q->where('read', false)]);
|
|
|
|
|
|
|
+ return $user->load([
|
|
|
|
|
+ 'position',
|
|
|
|
|
+ 'sector',
|
|
|
|
|
+ 'dependents' => function ($query) {
|
|
|
|
|
+ $query->where('status', 'approved');
|
|
|
|
|
+ },
|
|
|
|
|
+ ])->loadCount([
|
|
|
|
|
+ 'notificationSends as unread_notifications_count' => fn($q) => $q->where('read', false),
|
|
|
|
|
+ ]);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function getAll(): Collection
|
|
public function getAll(): Collection
|
|
@@ -36,9 +43,9 @@ class UserService
|
|
|
public function getAssociadosForSelect(?string $search, int $perPage): \Illuminate\Pagination\LengthAwarePaginator
|
|
public function getAssociadosForSelect(?string $search, int $perPage): \Illuminate\Pagination\LengthAwarePaginator
|
|
|
{
|
|
{
|
|
|
return $this->baseQuery([
|
|
return $this->baseQuery([
|
|
|
- 'type' => UserTypeEnum::ASSOCIADO->value,
|
|
|
|
|
- 'search' => $search,
|
|
|
|
|
- ])
|
|
|
|
|
|
|
+ 'type' => UserTypeEnum::ASSOCIADO->value,
|
|
|
|
|
+ 'search' => $search,
|
|
|
|
|
+ ])
|
|
|
->where('status', UserStatusEnum::ACTIVE)
|
|
->where('status', UserStatusEnum::ACTIVE)
|
|
|
->orderBy('name')
|
|
->orderBy('name')
|
|
|
->paginate($perPage, ['id', 'name', 'registration']);
|
|
->paginate($perPage, ['id', 'name', 'registration']);
|
|
@@ -96,8 +103,8 @@ class UserService
|
|
|
|
|
|
|
|
$query->where(function ($q) use ($term, $cpfTerm) {
|
|
$query->where(function ($q) use ($term, $cpfTerm) {
|
|
|
$q->whereRaw('UNACCENT(LOWER(name)) LIKE UNACCENT(?)', [$term])
|
|
$q->whereRaw('UNACCENT(LOWER(name)) LIKE UNACCENT(?)', [$term])
|
|
|
- ->orWhereRaw('UNACCENT(LOWER(email)) LIKE UNACCENT(?)', [$term])
|
|
|
|
|
- ->orWhereRaw('UNACCENT(LOWER(COALESCE(registration, \'\'))) LIKE UNACCENT(?)', [$term]);
|
|
|
|
|
|
|
+ ->orWhereRaw('UNACCENT(LOWER(email)) LIKE UNACCENT(?)', [$term])
|
|
|
|
|
+ ->orWhereRaw('UNACCENT(LOWER(COALESCE(registration, \'\'))) LIKE UNACCENT(?)', [$term]);
|
|
|
|
|
|
|
|
if ($cpfTerm) {
|
|
if ($cpfTerm) {
|
|
|
$q->orWhere('cpf', 'LIKE', $cpfTerm);
|
|
$q->orWhere('cpf', 'LIKE', $cpfTerm);
|