DONE: phone number verification, admin can add user employment; WIP: wire with onewaysms

This commit is contained in:
ISMAIL MASSERAN
2026-07-12 12:36:46 +08:00
parent 431bbee17c
commit a11b75729a
37 changed files with 2214 additions and 73 deletions
@@ -46,6 +46,31 @@ class UserRepository implements UserRepositoryInterface
}
}
private function applyCompanyNameFilter($query, string $companyName): void
{
if ($companyName === '') {
return;
}
$query->whereHas('employments', function ($employmentQuery) use ($companyName) {
$employmentQuery
->where('company_name', $companyName)
->whereRaw('employments.id = (
SELECT e2.id
FROM employments e2
WHERE e2.user_id = employments.user_id
ORDER BY e2.is_current DESC, e2.start_date DESC
LIMIT 1
)');
});
}
private function applyListFilters($query, array $filters): void
{
$this->applyDateRangeFilters($query, $filters);
$this->applyCompanyNameFilter($query, $filters['company_name'] ?? '');
}
/**
* Get all Users with pagination and search
*/
@@ -107,7 +132,7 @@ class UserRepository implements UserRepositoryInterface
$query->where('status', $status);
}
$this->applyDateRangeFilters($query, $dateFilters);
$this->applyListFilters($query, $dateFilters);
return $query->paginate($perPage);
}
@@ -177,7 +202,7 @@ class UserRepository implements UserRepositoryInterface
$baseQuery->where('status', $status);
}
$this->applyDateRangeFilters($baseQuery, $dateFilters);
$this->applyListFilters($baseQuery, $dateFilters);
$total = (int) (clone $baseQuery)->count();