get all unique row with having one column which is not primary key distinct in laravel:
$datas= Modelname::select()->groupBy('field_name')->get();
now,
you will get the error something like non aggrigated bla bla.. so for this you need is ..
just go to database.php file inside config folder and
find 'strict' and make it false
$datas= Modelname::select()->groupBy('field_name')->get();
now,
you will get the error something like non aggrigated bla bla.. so for this you need is ..
just go to database.php file inside config folder and
find 'strict' and make it false
'strict' => false,
now you are done ... you will get the required datas correctly
Comments
Post a Comment