1
Hello, I am studying Laravel I’m using the version 5.4, I need some help 'cause I’m not getting back the total records from last week’s database, I managed to return the total, and the total of the month, but the total of the last week.
Making it clear that what I couldn’t get was to return the total of data from the last 7 days of the database.
Here is my Controller:
public function index(){
$users = DB::table('clientes')->count();
$semana = date("d")-7;
$usersemanal = DB::table('clientes')->whereDate('created_at', $semana)->count();
$mes = date('m');
$totalusers = DB::table('clientes')->whereMonth("created_at",$mes)->count();
return view('dashboard', compact('users', 'totalusers', 'usersemanal'));
}
This is the part of the code I made to return last week but I can’t get anywhere.
Some solution or other way to make this return?
$semana = date("d")-7;
$usersemanal = DB::table('clientes')->whereDate('created_at', $semana)->count();
Thanks for your help.