Problems with unique records laravel 5.5


Since I have had problems with the plunk() method I have tried to find a way to translate this query to Eloquent, but until now I have not succeeded, is there any other way?

select distinct usuario_ad from usuarios;
asked by zereft 15.12.2018 в 22:57

1 answer


Your query should occupy the distinct () method, but you can also use the raw () method to write the method in sql.

With Eloquent Laravel:

$data = User::select("usuario_ad")

Or with the query builder

$data = \DB::table("usuarios")
answered by 15.12.2018 / 23:14