I am trying to get the sum of a field 'time_spent' for the current month, so when it's the next month it will start over again. I currently have in my model:
public function transactions()
{
return Transaction::groupBy('created_at')
->selectRaw('sum(time_spent) as sum')
->pluck('sum');
}
Then in my blade view I am calling using:
$info->transactions()->sum()
This does return the sum of time_spent from the DB, but it doesn't care about the created_at, I am assuming its not using it, My column for created_at is timestamp()