Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sum of a calculation, is it possible #80

Open
JuanCar29 opened this issue Jan 30, 2025 · 1 comment
Open

Sum of a calculation, is it possible #80

JuanCar29 opened this issue Jan 30, 2025 · 1 comment

Comments

@JuanCar29
Copy link

It is possible to make a sum from the multiplication of 2 columns. I have tried creating an attribute, but it doesn't work.

@JuanCar29
Copy link
Author

I have managed to do it

$data = Trend::model(Sale::class)
->between(
start: now()->startOfMonth()->subMonth(),
end: now()->endOfMonth()->subMonth(),
)
->perDay()
->sum('precio * cantidad');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant