I'm starting to work with Laravel and I need to make a query in the database, it's a simple query, but as I'm starting I still do not know how to do it.
I need to get the sales made today, yesterday, this month, previous month, current year and previous year , but first I need to make this query work in Laravel, builder .
SELECT
SUM(TotalVenda) as TotalVenda
FROM vendas
WHERE DATE(dtRegistro) = CURDATE()
I'm having difficulty joining syntax statements, for example:
$datas = DB::table('vendas')
->whereDate('dtRegistro', Carbon::now()->format('m/d/Y'))
->get();
After that I need to get the sum of the result obtained, but in this example even it no longer returns the expected date records that would be today.