feat: add tag filtering to blog posts and implement JSON_CONTAINS DQL function

This commit is contained in:
hamed
2026-06-21 17:34:07 +03:30
parent 91cfb64217
commit 21b6c583c0
5 changed files with 69 additions and 10 deletions
+3 -2
View File
@@ -60,9 +60,10 @@ class BlogController extends BaseController
{
$page = max(1, (int) $request->query->get('page', 1));
$limit = min(50, max(1, (int) $request->query->get('limit', 20)));
$tag = $request->query->get('tag') ?: null;
$blogs = array_map(fn(Blog $b) => $b->toListArray(), $this->blogRepo->findPublished($page, $limit));
$total = $this->blogRepo->countPublished();
$blogs = array_map(fn(Blog $b) => $b->toListArray(), $this->blogRepo->findPublished($page, $limit, $tag));
$total = $this->blogRepo->countPublished($tag);
return $this->paginated($blogs, $total, $page, $limit);
}