Сортировка по пользовательскому запросу не работает с Paginator - PullRequest
0 голосов
/ 29 сентября 2018

Попытка заставить paginator работать, чтобы я мог сортировать отчеты, но он не работает.Ни один из столбцов не будет отсортирован.Есть ли способ сделать это с Paginator?Это CakePHP 3.5.17.

Запрос

    $objQuery = TableRegistry::get('Reservation')->find();

    $unconfirmed = $objQuery->newExpr()->addCase(
        $objQuery->newExpr()->add(['Reservation.status' => 'unconfirmed']),
        1,
        'integer'
    );

    $objQuery->select([
            'Publisher.id',
            'Publisher.name',
            'count' => $objQuery->func()->count('Reservation.publisher_id'),
            'unconfirmed' => $objQuery->func()->count($unconfirmed),
            'sum_total' => $objQuery->func()->sum('Reservation.total_charge * Reservation.usd_value'),
            'sum_room_charge' => $objQuery->func()->sum('Reservation.room_charge * Reservation.usd_value'),
            'sum_nights' => $objQuery->func()->sum(
                'datediff(ReservationPropertyAccommodation.checkout, ReservationPropertyAccommodation.checkin)'
            ),
        ])
        ->contain([
            'Publisher',
            'ReservationPropertyAccommodation'
        ]);

    $objQuery->group('publisher_id');

    $this->paginate = [
        'limit' => 100,
        'order' => ['Publisher.name' => 'asc'],
    ];

    $reservations = $this->paginate($objQuery);

HTML / Paginator View Helper

<th scope="col"><?= $this->Paginator->sort('publisher.name', 'Publisher') ?></th>
<th scope="col"><?= $this->Paginator->sort('count', 'Reservations') ?></th>
<th scope="col"><?= $this->Paginator->sort('unconfirmed', 'Unconfirmed') ?></th>
<th scope="col"><?= $this->Paginator->sort('sum_nights', 'Nights Booked') ?></th>
<th scope="col">ADR</th>
<th scope="col"><?= $this->Paginator->sort('sum_room_charge', 'Room Revenue') ?></th>

IПредположим, я мог бы использовать сортировку на стороне клиента для чего-то вроде этого, возможно Datatables, но мне все еще интересно, как это решить.

...