From 94b11a7f18b5a7efa52250cfcdcfa9d44f0272ca Mon Sep 17 00:00:00 2001 From: baodev0 Date: Tue, 20 Oct 2026 09:58:38 +0700 Subject: [PATCH] update --- .../Api/Admin/Dashboard/DashboardController.php | 7 +++++-- app/Repositories/Employee/EmployeeRepository.php | 6 +++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Api/Admin/Dashboard/DashboardController.php b/app/Http/Controllers/Api/Admin/Dashboard/DashboardController.php index 194502c..39c8748 100644 --- a/app/Http/Controllers/Api/Admin/Dashboard/DashboardController.php +++ b/app/Http/Controllers/Api/Admin/Dashboard/DashboardController.php @@ -387,7 +387,7 @@ class DashboardController extends Controller $limit = max(1, min(30, $limit)); // Tổng hợp 3 nguồn rồi sort theo thời gian - $orders = Order::with('customer:id,fullname') + $orders = Order::with('customer:id,fullname,email') ->orderByDesc('created_at') ->limit($limit) ->get() @@ -405,12 +405,13 @@ class DashboardController extends Controller default => 'được tạo', }, 'description' => ($o->customer->fullname ?? '—') . ' · ' . number_format((float) $o->total, 0, ',', '.') . 'đ', + 'customer_email' => $o->customer->email ?? null, 'created_at' => $o->created_at?->toISOString(), '_ts' => $o->created_at?->timestamp ?? 0, ]; }); - $deposits = Transaction::with('customer:id,fullname') + $deposits = Transaction::with('customer:id,fullname,email') ->whereIn('type', self::DEPOSIT_TYPES) ->orderByDesc('created_at') ->limit($limit) @@ -422,6 +423,7 @@ class DashboardController extends Controller 'type' => $ok ? 'deposit_success' : 'deposit_failed', 'title' => $ok ? 'Nạp tiền thành công' : 'Giao dịch nạp thất bại', 'description' => ($t->customer->fullname ?? '—') . ' · ' . number_format((float) $t->amount, 0, ',', '.') . 'đ', + 'customer_email' => $t->customer->email ?? null, 'created_at' => $t->created_at?->toISOString(), '_ts' => $t->created_at?->timestamp ?? 0, ]; @@ -435,6 +437,7 @@ class DashboardController extends Controller 'type' => 'customer_registered', 'title' => 'Khách hàng mới đăng ký', 'description' => ($c->fullname ?: $c->email) ?? '—', + 'customer_email' => $c->email, 'created_at' => $c->created_at?->toISOString(), '_ts' => $c->created_at?->timestamp ?? 0, ]); diff --git a/app/Repositories/Employee/EmployeeRepository.php b/app/Repositories/Employee/EmployeeRepository.php index f8415b0..98ad2ef 100644 --- a/app/Repositories/Employee/EmployeeRepository.php +++ b/app/Repositories/Employee/EmployeeRepository.php @@ -26,7 +26,11 @@ class EmployeeRepository extends BaseRepository implements EmployeeRepositoryInt } if (!empty($data['role'])) { - $query->whereHas('roles', fn($q) => $q->where('name', $data['role'])); + $query->whereHas('roles', fn($q) => $q->whereIn('name', (array) $data['role'])); + } + + if (isset($data['status']) && $data['status'] !== []) { + $query->whereIn('status', (array) $data['status']); } $perPage = $data['per_page'] ?? 15;