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
+15 -2
View File
@@ -18,10 +18,13 @@ class AdminController extends Controller
{
$selectedMonth = $request->input('month', Carbon::now()->format('Y-m'));
$search = $request->input('search');
$status = $request->input('status', (string)User::STATUS_ACTIVE);
$role = $request->input('role');
$department = $request->input('department');
$flagSend = $request->input('flag_send');
['users' => $users, 'topReceivedUser' => $topReceivedUser, 'topSentUser' => $topSentUser]
= $this->adminService->getUserListWithStats($selectedMonth, $search, $flagSend);
= $this->adminService->getUserListWithStats($selectedMonth, $search, $status, $role, $department, $flagSend);
if ($request->ajax() || $request->wantsJson()) {
return response()->json([
@@ -31,7 +34,17 @@ class AdminController extends Controller
]);
}
return view('admin.users.index', compact('users', 'selectedMonth', 'topReceivedUser', 'topSentUser', 'search', 'flagSend'));
return view('admin.users.index', compact(
'users',
'selectedMonth',
'topReceivedUser',
'topSentUser',
'search',
'status',
'role',
'department',
'flagSend'
));
}
public function create()
@@ -75,6 +75,10 @@ class UserController extends Controller
{
$request->validate([
'password' => 'required|min:6|confirmed',
], [
'password.required' => 'Mật khẩu mới không được để trống.',
'password.min' => 'Mật khẩu mới phải có ít nhất 6 ký tự.',
'password.confirmed' => 'Mật khẩu xác nhận không trùng khớp.',
]);
$user = Auth::user();
+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');
}
@@ -6,7 +6,14 @@ use Illuminate\Pagination\LengthAwarePaginator;
interface 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;
public function getUserTransactions(string $msnv, string $selectedMonth): LengthAwarePaginator;