I am trying to get this current week's data from my table
I have the following code which gives me 31 days of data (A month but it's seperated)
$stats["tmv"] = "";
$stats["tmd"] = "";
$stats["tru"] = array();
for ($i=1; $i <= 31; $i++) {
$stats["tmv"] .= DB::table('stats')->select(DB::raw('*'))->where(DB::raw('DAY(created_at)'), '=', $i)->where('stats_type', "mv")->count();
$stats["tmd"] .= DB::table('stats')->select(DB::raw('*'))->where(DB::raw('DAY(created_at)'), '=', $i)->where('stats_type', "md")->count();
$stats["tru"][$i] = DB::table('users')->select(DB::raw('*'))->where(DB::raw('DAY(created_at)'), '=', $i)->count();
if ($i != 31) {
$stats["tmv"] .= ",";
$stats["tmd"] .= ",";
}
}
Output: "tmv" => "11,4,1,13,0,5,15,2,0,24,1,7,17,18,45,14,31,61,3,1,4,1,1,27,30,47,18,60,10,0,156"
How do I edit my query to select this current week's data?
via rebirth1078