Laravel 4 - пагинация игнорируется отчетливо

Я делаю беглый запрос с отчетливым и paginate. Моя проблема заключается в том, что запрос paginate выполняется перед запросом disinct

Мой свободный запрос:

$candidates = DB::table('candidates')
            ->select('candidates.*')
            ->distinct()
            ->join('candidate_region', 'candidates.id', '=', 'candidate_region.candidate_id')
            ->join('candidate_job', 'candidates.id', '=', 'candidate_job.candidate_id')
            ->whereIn('candidate_region.region_id', $inputs['region'])
            ->whereIn('candidate_job.job_id', $inputs['job'])
            ->where('imavailable', '1')
            ->where('dateDisponible', '<=', $inputs['availableDate'])
            ->paginate(15);

Я проверяю свой запрос с DB :: getQueryLog ()

$query = DB::getQueryLog($candidates);

$ query показывает, что запрос разбит на страницы (со счетчиком) для страницы make number:

5 => 
array (size=3)
     'query' => string 'select count(*) as aggregate from `candidates` inner join `candidate_region` on `candidates`.`id` = `candidate_region`.`candidate_id` inner join `candidate_job` on `candidates`.`id` = `candidate_job`.`candidate_id` where `candidate_region`.`region_id` in (?, ?, ?, ?, ?) and `candidate_job`.`job_id` in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) and `imavailable` = ? and `dateDisponible` <= ?' (length=396)

И мой запрос с отчетливым является выполнить после paginate:

6 => 
array (size=3)
  'query' => string 'select distinct `candidates`.* from `candidates` inner join `candidate_region` on `candidates`.`id` = `candidate_region`.`candidate_id` inner join `candidate_job` on `candidates`.`id` = `candidate_job`.`candidate_id` where `candidate_region`.`region_id` in (?, ?, ?, ?, ?) and `candidate_job`.`job_id` in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) and `imavailable` = ? and `dateDisponible` <= ? limit 15 offset 15' (length=417)

Как сделать для выполнения запроса, отличного перед paginate?

Спасибо

Ответы на вопрос(2)

Ваш ответ на вопрос