Hello! Need help to build a laravel query.
I'm trying to access the latest messages from a table with content:
message_id -> incremented value
from_id -> can be either $userId or another id
to_id -> can be either $userId or another id
message -> the message
created_at -> timestamp
A user's user id can appear in both the to and from column and multiple times for another user . How should I write a Laravel query which selects the most recent sent message between two users?
Need help asap!