I try to get the rows but without duplicates, I try to filter the duplicates by the "date_payment" column.
$datos = DB::table('quincenas')->distinct('fecha_pago')->get();
return view('employees\reports\fortnights')->with('data',$data);
Also tried like this:
$datos = DB::table('quincenas')->distinct()->get();
return view('employees\reports\fortnights')->with('data',$data);
Result:
From documentation 1 and I quote:
Which could be translated as:
You should use the method
select()
to indicate which column to apply thedistinct()
, that is, the one you want to filter by different values:Example code:
Or if you are going to do it through the query constructor it can be like this:
As you can see in both cases (which I have already tested) you must use the method
select
to pass the desired column as an argument and then chain the method that will bring different values.References