1 year ago

Two seemingly identical collections, but one fails where the other does not

Posted 1 year ago by ristlin

I have one collection that I've put together like so:

// First collection
$payment_records = $user->payout_record->merge($user->pay_received_record);

The other sorts that collection.

// Second collection
$sorted_payment_records = $payment_records->sortByDesc('updated_at');

When I dump both, I get what looks to me to be an identical structure: collections with an array of objects. The first collection when passed through to a Vue component can be manipulated with array methods like filter and sort. When I pass the second collection instead, the same array methods fail.

What am I missing?

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