feat: add tag filtering to blog posts and implement JSON_CONTAINS DQL function
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user