Please how to setup $this->paginate
if query contained data?
$Query = $this->Users->find()
->contain([
'UsersDocuments' => function (\Cake\ORM\Query $q) {
return $q
->contain([
'Orders'
])
->order(['UsersDocuments.date' => 'DESC'])
->limit(1);
}
]);
$Content = $this->paginate($Query, []);
I would like to sort by the column that is in the Orders model