Last active
May 4, 2023 13:21
-
-
Save sonichandni/99f143ac48b4e9064a534199545dfa88 to your computer and use it in GitHub Desktop.
date wise data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Carbon\Carbon; | |
use DB; | |
// For today | |
$activationKeyCount['today'] = KeyBatchGroupKeys::select('id')->whereDate('d_activation_date', Carbon::today())->count(); | |
// For yesterday | |
$activationKeyCount['yesterday'] = KeyBatchGroupKeys::select('id')->whereDate('d_activation_date', Carbon::yesterday())->count(); | |
// For this week | |
$startOfWeek = Carbon::now()->startOfWeek()->setTime(0, 0, 0); | |
$endOfWeek = Carbon::now()->endOfWeek()->setTime(23, 59, 59); | |
$activationKeyCount['this_week'] = KeyBatchGroupKeys::select('id')->whereBetween('d_activation_date', [$startOfWeek, $endOfWeek])->count(); | |
// For this month | |
$startOfMonth = Carbon::now()->startOfMonth()->setTime(0, 0, 0); | |
$endOfMonth = Carbon::now()->endOfMonth()->setTime(23, 59, 59); | |
$activationKeyCount['this_month'] = KeyBatchGroupKeys::select('id')->whereBetween('d_activation_date', [$startOfMonth, $endOfMonth])->count(); | |
// For this year | |
$startOfYear = Carbon::now()->startOfYear()->setTime(0, 0, 0); | |
$endOfYear = Carbon::now()->endOfYear()->setTime(23, 59, 59); | |
$activationKeyCount['this_year'] = KeyBatchGroupKeys::select('id')->whereBetween('d_activation_date', [$startOfYear, $endOfYear])->count(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment