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

panthro's avatar

How to select distinct records in eloquent

I'm trying to select unique records using distinct but I am getting repeated records as I have a value in one field that differs.

Is there a way to specify to exclude this field or can I use distinct and specify the column(s) that should be distinct?

0 likes
2 replies
Snapey's avatar
    Model::distinct('column_name')->pluck('column_name);

will give you an array of distinct column_name values from the table.

Perhaps you don't mean distinct

1 like

Please or to participate in this conversation.