- /**
- * Search for images by query, of a particular type.
- * @param string $type
- * @param int $page
- * @param int $pageSize
- * @param string $searchTerm
- * @return array
- */
- public function searchPaginatedByType($type, $searchTerm, $page = 0, $pageSize = 24)
- {
- $images = $this->image->where('type', '=', strtolower($type))->where('name', 'LIKE', '%' . $searchTerm . '%');
- return $this->returnPaginated($images, $page, $pageSize);
+ // Filter by page access
+ $imageQuery = $this->restrictionService->filterRelatedEntity(Page::class, $imageQuery, 'images', 'uploaded_to');
+
+ if ($whereClause !== null) {
+ $imageQuery = $imageQuery->where($whereClause);
+ }
+
+ return $this->returnPaginated($imageQuery, $page, $pageSize);