I have collection in Laravel:
Collection {#450 ▼
#items: array:2 [▼
0 => Announcement {#533 ▶}
1 => Announcement {#553 ▶}
]
}
You can unique the data set from the SQL level with groupBy + Max Try below
YourModelName::select(DB::raw('max(`town_short_name`) as town' 'town_long_name'))
->groupBy(['town_short_name'])
->without('postalCode','country','countryState')
->where('town_short_name','like','%'.$townName.'%')
->limit(100)
->orderBy('town_short_name');