Problems with unique records laravel 5.5

2

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
source

1 answer

1

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")
            ->distinct()
            ->get();

Or with the query builder

$data = \DB::table("usuarios")
           ->select("usuario_ad")
           ->distinct()
           ->get();
    
answered by 15.12.2018 / 23:14
source