-
Notifications
You must be signed in to change notification settings - Fork 11.2k
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
[5.7] Add withAggregate #25319
[5.7] Add withAggregate #25319
Conversation
add withSum to framework . in the past people try to add withMax withMin withAvg withSum and ... together and implements withCount i think its should be separte because in withSum withAvg and... we should determine what column but in withCount we dont so i add withSum if you think its ok( i test it ) add withAvg and .... . im not pro to do that soory for my bad english
I change some methods and add withSum withCount withMin withMax withAvg that use witheAggregate that support all aggregate i add somet migrations and seed in test/migration and test against real database (i'm not sure its right way but i dont have better idea) hope its working .
reference to : #25290 |
Can you check why do your tests fail? |
Hi. can you tell me what error you got because i test them before PR . by the way as i mentioned i think my tests specially migrations and seed tables is hard for test . and i don't have idea that how can i create proper test against database.anyway if you can tell me you have syntax error or fail assertion. |
Check the results form Travis: https://travis-ci.org/laravel/framework/builds/420002512?utm_source=github_status&utm_medium=notification |
you are right i didn't check travis. i will try to fix tests |
Since last time we tried this it caused a lot of problems, I want to this vetted as a package first. Both the builder and relation class are Macroable, so you should be able to macro these methods into the classes. If that package works without issue for people I will merge this into the core. |
This would be really nice feature. Hope it will get merged one day. But for now, I found little workaround, which works in Laravel 5.7. Not probably the best solution, but it does the work User::withCount(['terms as term_sum' => function($query){
$query->select(DB::raw('SUM(id)'));
}]) |
I actually ended up breaking this out into a package: |
@arxeiss mindblowing hacking. That workaround is amazing. |
@dwightwatson absolute life saver. I needed |
No description provided.