Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jcgivens21's avatar

Not sure how to handle ordering this collection

I have 3 tables (bids, bid_item_headers, bid_item). Here is a picture of the table contents (https://s24.postimg.org/m02twv6h1/temp_Table.png)

The "bids" table contains columns that specify the id's of the other 2 tables.

I create a collection that pulls in the 'bids' objects using collect() on the bids table. Now I want to sort it based on the 'identifier' values in bid_item_header.identifier, and then sub-sort it by bid_item.identifer

I want to be able to sort it so that if I were to print out: "bids.id | bid_item_headers.identifier | bid_item.identifier" the order (based on my table data) should show up like this:

12 | 1000 | 1002

6 | 2000 | 2003

11 | 3000 | 3001

10 | 3000 | 3003

I just don't know how to sort the "bids" collection based on the values found in the other tables, when all I have is the 'ids' of those other tables in the bids table.

My apologies if this is poorly explained. Looking for any help I can get :-)

0 likes
1 reply
jcgivens21's avatar

Any thoughts? Do I need to reword the question? Thanks.

Please or to participate in this conversation.