Laravel +postgresql groupby query

Published 9 months ago by imtiyaz004

I have Model Called "Package". I want to use "SELECT * FROM package WHERE type='domestic' GROUP BY state" query with Laravel postgresql . How can i write this query using "Package" Model.

Best Answer (As Selected By imtiyaz004)
Dry7

@imtiyaz004

Package::where('type', 'domestic')->groupBy('state')
but the original query is incorrect, it is worth writing

Package::select('state')->where('type', 'domestic')->groupBy('state')
Dry7
Dry7
9 months ago (151,880 XP)

@imtiyaz004

Package::where('type', 'domestic')->groupBy('state')
but the original query is incorrect, it is worth writing

Package::select('state')->where('type', 'domestic')->groupBy('state')

Please sign in or create an account to participate in this conversation.