cakephp 4.x
I am trying to get the 5 latest loaded images (in a plugin called medias).
So I tried (in src->Model->Table :
$this->hasMany('LatestFiles', [
'className' => 'Medias.Fichiers',
'foreignKey' => 'dossier_id',
'strategy' => 'select',
'queryBuilder' => function ($q) use($imageTypes) {
return $q->where(['LatestFiles.filetype IN' => $imageTypes])->order(['LatestFiles.modified' => 'DESC'])->limit(5);
}
]);
and in the controller :
->contain([ 'LatestFiles'])
but the limit does not work. It returns all images.
I am sure that I am very close but where ?