Here is a little bit of information about the problem - I am currently using google maps to create a small application where people have a profile page which contains a Google map. They can drop markers on that map and stuff like city, country, latitude, and longitude of these markers gets saved in the database.
Now I want to create a list of cities which have been marked, however, if a User creates 2 marks in a certain city, the name of that city gets displayed twice which is unwanted behavior. This is why I am wondering whether I can exclude the duplicate record from my collection, for example, if I have this:
Database records:
id city country lat lng
1 London UK 1 1
2 London UK 1 1
3 Tokyo Japan 2 2
Is it possible to only return 2 records based on the city, the first one and the third one while excluding the second one because it's duplicate?
I'm currently getting the cities like this:
$cities = Marker::where('user_id', $userId)->get();
Table: Markers
Columns: id, city, country, place_id, user_id, lat, lng, created_at, updated_at