I have a model A
that has a relationship of type HAS_MANY
with model B
.
B
's attributes are:
id,
user_id,
message,
date,
parent_message_id
I need elements of model B
to be ordered by date (descending), but in case the parent_message_id
is different from null, the date to be taken into consideration should be the date corresponding to parent_message_id
.
Is it possible to customize the criteria used to order the relation?