diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index bb17762..fb017ea 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -47,7 +47,23 @@ SQL abort(404); } - return view('user.stats')->with(compact('user')); + $groupByDay = Ejaculation::select(DB::raw(<<<'SQL' +to_char(ejaculated_date, 'YYYY/MM/DD') AS "date", +count(*) AS "count" +SQL + )) + ->where('user_id', $user->id) + ->where('ejaculated_date', '>=', Carbon::now()->addMonths(-9)->firstOfMonth()) + ->groupBy(DB::raw("to_char(ejaculated_date, 'YYYY/MM/DD')")) + ->orderBy(DB::raw("to_char(ejaculated_date, 'YYYY/MM/DD')")) + ->get(); + $calendarData = []; + foreach ($groupByDay as $data) { + $timestamp = Carbon::createFromFormat('Y/m/d', $data->date)->getTimestamp(); + $calendarData[$timestamp] = $data->count; + } + + return view('user.stats')->with(compact('user', 'calendarData')); } public function okazu($name) diff --git a/resources/views/user/stats.blade.php b/resources/views/user/stats.blade.php index b1f135e..74e21de 100644 --- a/resources/views/user/stats.blade.php +++ b/resources/views/user/stats.blade.php @@ -1,10 +1,35 @@ @extends('user.base') +@push('head') + +@endpush + @section('tab-content') @if ($user->is_protected && !$user->isMe())

このユーザはチェックイン履歴を公開していません。

@else +
Shikontribution graph
+
+
@endif -@endsection \ No newline at end of file +@endsection + +@push('script') + + + +@endpush \ No newline at end of file