Try to select distinct in other relationship

Hi guys.I have a Model by some relationship with other Models.I am going to find all users that send some file with select distinct users.it means a users can send some file.But i want to find all users that send a file.I want to just find unique users.I use cakephp 3.2.Thanks

You should have a look at http://book.cakephp.org/3.0/en/orm/retrieving-data-and-resultsets.html#filtering-by-associated-data and use distict() to filter the result so users come up only once.

No.I want to distinct in just relation Model for example my problem is like this code
$query = $articles->find('all') ->where(['Articles.created >' => new DateTime('-10 days')]) ->contain(['Comments'=>['fields'=>['distinct user_id'], 'Authors']) ->limit(10);

You can use a callback function in contain like this:

$query = $articles->find('all')
    ->where(['Articles.created >' => new DateTime('-10 days')])
    ->contain(['Authors', 'Comments' => function ($q) {
        return $q->distinct('user_id');
    })
    ->limit(10);