2

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.

Samantha Roseman
  • 113
  • 1
  • 1
  • 9

1 Answers1

6

Figured it out. This is what I needed to append to the Eloquent query builder

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

Samantha Roseman
  • 113
  • 1
  • 1
  • 9