create account

Eloquent Grouping By Relation by penderis

View this thread on: hive.blogpeakd.comecency.com
· @penderis · (edited)
$12.28
Eloquent Grouping By Relation
There is a big focus for many on the type of framework or libraries they will be using within their applications. Some people like very slim frameworks... Others prefer things that just build the application for you. 

I like them in between. As I have written before the Node MVVC, MVC, MVEC ... are any of those real? Anyway, the Nodejs ecosystem is broad but far from convenient. 

This is why I went with Laravel recently, and it is not Javascript so always happy when I can relax and not have to read about how to do everything in Mongo Db when I just want to know from which damn folder to serve my views...

Yeah, I am an idiot, it is the views folder of course. Once I make it, then go change settings in about 5 different places. Looking at you Nest. 

Anyway, now you know why this is in the fuckit tag, because I have no clue what I am writing about and I don't care. 

One thing I recently sat a bit with and tried to be overly clever about, is also the title of this post. That is Laravel's Eloquent ORM and my need to query the database as though it was an AI. 

So as a reminder to my future self. 

<h3>Remind in 30 minutes</h3>
No <a href="https://laravel.com/docs/8.x/queries">GroupBy </a> cannot be used as a Eloquent method. It is a query builder method. Ok and it is an Eloquent method but not to query SQL. 

<h4>Remind of reminder</h4>
<a href="https://laravel.com/docs/8.x/collections">GroupBy</a> is also collection method, that is the result of a Eloquent query. 

<h5>Reminder..Page 2...</h5>
You (me) cannot use the convenient pagination from Laravel with GroupBy, unless you write your own. You will make the load on the database too much if you try aggregate 4 different tables results. Give it up. 

<h3>Maybe Mongo it.</h3>
Do create a pivot - not pivot table. Feels like duplication? Get the fuck over it. Gets the job done? Well yeah. Setup Eloquent relations for the mega pivot containing the keys to all tables, and the extra information you are trying to compute filled by some trigger be that a Cron, Action (Event) or just manually. 

Use nested <a href="https://laravel.com/docs/8.x/eloquent-relationships">Relations</a> to then paginate, WITH the related data and just loop the data so you can get on with it already. 

<h3>Read reminder</h3>
Dear past idiot, this future idiot has found a better way but thanx I would not have if I did not just fuckforward. Regards.
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 231 others
properties (23)
authorpenderis
permlinkeloquent-grouping-by-relation
categoryhive-133617
json_metadata{"links":["https://laravel.com/docs/8.x/queries","https://laravel.com/docs/8.x/collections","https://laravel.com/docs/8.x/eloquent-relationships"],"tags":["hive-133617","coding","gist","story","web-development","rant","proofofbrain","pal","fuckforward","laravel"],"app":"ecency/3.0.19-vision","format":"markdown+html"}
created2021-10-12 18:59:03
last_update2021-10-12 19:00:39
depth0
children5
last_payout2021-10-19 18:59:03
cashout_time1969-12-31 23:59:59
total_payout_value6.197 HBD
curator_payout_value6.084 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length2,408
author_reputation144,707,667,838,898
root_title"Eloquent Grouping By Relation"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id106,986,221
net_rshares11,741,537,470,028
author_curate_reward""
vote details (295)
@dreemsteem ·
$0.05
i do not think your reminders - your reminders of reminders - or your reminder to read your reminder usually works LOL

i think it is like your alarms
and we know how they work. hahahaaha


you wrote a post - AND i saw you comment on something that i commented on after you.

who are you.
👍  , , ,
properties (23)
authordreemsteem
permlinkre-penderis-r0vpda
categoryhive-133617
json_metadata{"tags":["hive-133617"],"app":"peakd/2021.09.1"}
created2021-10-12 19:12:48
last_update2021-10-12 19:12:48
depth1
children4
last_payout2021-10-19 19:12:48
cashout_time1969-12-31 23:59:59
total_payout_value0.026 HBD
curator_payout_value0.025 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length288
author_reputation372,180,742,165,102
root_title"Eloquent Grouping By Relation"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id106,986,494
net_rshares51,407,599,299
author_curate_reward""
vote details (4)
@penderis ·
$0.05
poor
👍  
properties (23)
authorpenderis
permlinkre-dreemsteem-r0vpge
categoryhive-133617
json_metadata{"tags":["hive-133617"],"app":"peakd/2021.09.1"}
created2021-10-12 19:14:39
last_update2021-10-12 19:14:39
depth2
children3
last_payout2021-10-19 19:14:39
cashout_time1969-12-31 23:59:59
total_payout_value0.026 HBD
curator_payout_value0.026 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length4
author_reputation144,707,667,838,898
root_title"Eloquent Grouping By Relation"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id106,986,520
net_rshares51,734,827,286
author_curate_reward""
vote details (1)
@dreemsteem ·
but you have two angels!!!!

so you are like... angel poor.

you know when you buy a big beautiful house, and you can't afford a can of beans until you pay off the mortgage in 30 years???

they call you house-poor.

well you are angel-poor :)


so that's like... nice  hehehe  cuz they're so pretty!  and special!!!!
properties (22)
authordreemsteem
permlinkre-penderis-r0vpv1
categoryhive-133617
json_metadata{"tags":["hive-133617"],"app":"peakd/2021.09.1"}
created2021-10-12 19:23:27
last_update2021-10-12 19:23:27
depth3
children2
last_payout2021-10-19 19:23:27
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length316
author_reputation372,180,742,165,102
root_title"Eloquent Grouping By Relation"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id106,986,687
net_rshares0