A
A
Alexey Verkhovtsev2017-07-25 21:00:52
Laravel
Alexey Verkhovtsev, 2017-07-25 21:00:52

How to extract only unique records from the database by field Laravel 5.1?

Hello. the task is this, I have 8 records with the desired center_id, there are repeated part_number, 103, 105, I need the center_id to be pulled out and the unique part_number field filtered. So instead of 8, I saw 2 entries. How to do it?
ad2310a8816b4fcf9ff20cbca3f4e6cc.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Verkhovtsev, 2017-07-25
@seftomsk

It turned out like this $this->centerPricesWithCurrency->where('center_id', $center_id)->groupBy('part_number')->get();

N
Nikita Dergachov, 2017-07-25
@vanillathunder

->groupBy('part_number')
->distinct()
->get()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question