Query Builder Raw Lateral Join with jsonb_to_recordset

By | August 20, 2018

Hopefully a very simple question. I’m trying to create a query within Laravel based off of my postgresql query, and I’m having a hard time converting this one specific join because it is a lateral join utilizing jsonb_to_recordset.

join lateral jsonb_to_recordset(gift_splits) as r("house_id" int, "amount" json) on true

This is what I have tried so far, and it says that I have too few arguments. I understand that it would like ‘a’, ‘=’, ‘b’, but I’m not sure how to translate ‘on true’ to that and also the lateral aspect of the join.

        ->join(DB::raw("lateral jsonb_to_recordset(gift_splits) as r(house_id int, amount json)"), true)

Lastly, I’ve tried having the entire query posted into Model::raw(DB::raw(“…, and I ran into a lot of little errors. I’d love feedback on my actual question.


Leave a Reply

Your email address will not be published. Required fields are marked *