You should use groupby
. In Query Builder you can do it this way:
$users = DB::table('users')
->select('id','name', 'email')
->groupBy('name')
->get();
More Related Contents:
- Laravel – Eloquent “Has”, “With”, “WhereHas” – What do they mean?
- Migration: Cannot add foreign key constraint
- Laravel Eloquent groupBy() AND also return count of each group
- Eloquent Collection: Counting and Detect Empty
- Eloquent eager load Order by
- Laravel Eloquent vs DB facade: Why use Eloquent and decrease performance? [closed]
- Laravel. Use scope() in models with relation
- Laravel Eloquent “WHERE NOT IN”
- HasManyThrough with one-to-many relationship
- Getting just the latest value on a joined table with Eloquent
- Laravel Migration Change to Make a Column Nullable
- Select Last Row in the Table
- How to select specific columns in laravel eloquent
- How to access model hasMany Relation with where condition?
- Eloquent push() and save() difference
- Laravel Eloquent – distinct() and count() not working properly together
- Laravel save / update many to many relationship
- First Or Create
- Laravel: Returning the namespaced owner of a polymorphic relation
- How to setup conditional relationship on Eloquent
- Polymorphic Eloquent relationships with namespaces
- Laravel Eloquent – Where In All
- Clone an Eloquent object including all relationships?
- Group by not working – Laravel
- How to insert multiple rows from a single query using eloquent/fluent
- Laravel – Eloquent or Fluent random row
- Creating and Update Laravel Eloquent
- How to sort a Laravel query builder result by multiple columns?
- global variable for all controller and views
- Laravel Eloquent: How to get only certain columns from joined tables