Laravel Eloquent - distinct() and count() not working properly together

前端 未结 12 1102
甜味超标
甜味超标 2020-12-04 15:54

So I\'m trying to get the number of distinct pids on a query, but the returned value is wrong.

This is what I try to do:

$ad->getcodes()->group         


        
12条回答
  •  情深已故
    2020-12-04 16:45

    You can use the following way to get the unique data as per your need as follows,

    $data = $ad->getcodes()->get()->unique('email');
    
    $count = $data->count();
    

    Hope this will work.

提交回复
热议问题