feature: change password

This commit is contained in:
antv
2026-07-08 13:03:48 +07:00
parent 63764d0718
commit 6056e33ef8
16 changed files with 371 additions and 56 deletions
+30 -12
View File
@@ -14,13 +14,18 @@ use Illuminate\Support\Facades\Hash;
class AdminService implements AdminServiceInterface
{
public function getUserListWithStats(string $selectedMonth, ?string $search = null, ?string $flagSend = null): array
{
public function getUserListWithStats(
string $selectedMonth,
?string $search = null,
?string $status = '1',
?string $role = null,
?string $department = null,
?string $flagSend = null
): array {
$startOfMonth = Carbon::parse($selectedMonth)->startOfMonth();
$endOfMonth = Carbon::parse($selectedMonth)->endOfMonth();
$usersQuery = User::select('user.*')
->where('status', User::STATUS_ACTIVE)
->addSelect([
'total_received' => Administration::selectRaw('COALESCE(SUM(received), 0)')
->whereColumn('msnv', 'user.msnv')
@@ -30,22 +35,35 @@ class AdminService implements AdminServiceInterface
->whereBetween('date', [$startOfMonth, $endOfMonth])
]);
$topReceivedUser = (clone $usersQuery)->orderByDesc('total_received')->first();
$topSentUser = (clone $usersQuery)->orderByDesc('total_sent')->first();
$topReceivedUser = (clone $usersQuery)->where('status', User::STATUS_ACTIVE)->orderByDesc('total_received')->first();
$topSentUser = (clone $usersQuery)->where('status', User::STATUS_ACTIVE)->orderByDesc('total_sent')->first();
if (!is_null($search) && trim($search) !== '') {
$search = trim($search);
$usersQuery->where(function ($q) use ($search) {
$q->whereRaw('LOWER(msnv) LIKE ?', ['%' . strtolower($search) . '%'])
->orWhereRaw('LOWER(mail) LIKE ?', ['%' . strtolower($search) . '%']);
});
if (!is_null($status) && $status !== '') {
$usersQuery->where('status', intval($status));
}
if (!is_null($role) && $role !== '') {
$usersQuery->where('role', intval($role));
}
if (!is_null($department) && $department !== '') {
$usersQuery->where('departments', intval($department));
}
if (!is_null($flagSend) && $flagSend !== '') {
$usersQuery->where('flag_send', intval($flagSend));
}
$users = $usersQuery->paginate(10)->withQueryString();
if (!is_null($search) && trim($search) !== '') {
$search = trim($search);
$usersQuery->where(function ($q) use ($search) {
$q->whereRaw('LOWER(msnv) LIKE ?', ['%' . strtolower($search) . '%'])
->orWhereRaw('LOWER(name) LIKE ?', ['%' . strtolower($search) . '%'])
->orWhereRaw('LOWER(mail) LIKE ?', ['%' . strtolower($search) . '%']);
});
}
$users = $usersQuery->paginate(20)->withQueryString();
return compact('users', 'topReceivedUser', 'topSentUser');
}