Answers for "Order by relation's column"

0

Order by relation's column

return $this->channels()
                ->leftJoin('replies', 'channels.id', '=', 'replies.channel_id')
                ->groupBy(['channels.id'])
                ->orderByRaw('max(replies.created_at) desc')
                ->get();
Posted by: Guest on August-26-2021

Browse Popular Code Answers by Language