From e89b65afdfdc3eec182a0e1056de5e4034eb4e8c Mon Sep 17 00:00:00 2001 From: Pig Fang Date: Sun, 22 Aug 2021 19:27:34 +0800 Subject: [PATCH] fix chart data (fix #336) --- app/Http/Controllers/AdminController.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php index 36c13381..24ec0c55 100644 --- a/app/Http/Controllers/AdminController.php +++ b/app/Http/Controllers/AdminController.php @@ -51,16 +51,18 @@ class AdminController extends Controller $oneMonthAgo = Carbon::today()->subMonth(); - $grouping = fn ($field) => fn ($item) => substr($item->$field, 5, 5); + $grouping = fn ($field) => fn ($item) => Carbon::parse($item->$field)->isoFormat('l'); $mapping = fn ($item) => count($item); $aligning = fn ($data) => fn ($day) => ($data->get($day) ?? 0); + /** @var Collection */ $userRegistration = User::where('register_at', '>=', $oneMonthAgo) ->select('register_at') ->get() ->groupBy($grouping('register_at')) ->map($mapping); + /** @var Collection */ $textureUploads = Texture::where('upload_at', '>=', $oneMonthAgo) ->select('upload_at') ->get()