Skip to content

Conversation

@mubbi
Copy link
Owner

@mubbi mubbi commented Jul 22, 2025

This pull request introduces a new feature for articles API, including support for retrieving articles with filtering, pagination, and detailed resource representation. It also adds relationships for articles with categories, tags, and authors. The key changes are grouped into the following themes:

New Controllers for Articles API

  • Added GetArticlesController to handle paginated retrieval of articles with filtering options, returning a structured JSON response.
  • Added ShowArticleController to retrieve a specific article by its slug, with detailed error handling for not found and server errors.

Request Validation and Resource Representation

  • Added GetArticlesRequest to validate and provide default values for article filtering and pagination parameters.
  • Added ArticleResource to transform article models into a standardized JSON structure, including relationships like author, categories, tags, and authors.

Database Relationships for Articles

  • Updated the Article model to include categories, tags, and authors relationships using BelongsToMany.
  • Modified the Category and Tag models to define articles as a BelongsToMany relationship. [1] [2]

Article Service for Business Logic

  • Added ArticleService to encapsulate the logic for retrieving articles with filters, sorting, and pagination, as well as fetching a single article by slug.

API Routes and Localization

  • Added new routes for listing and showing articles in the api_v1.php file.
  • Added a localization string for "Resource not found" in common.php.

@mubbi mubbi requested a review from Copilot July 22, 2025 20:52
@mubbi mubbi self-assigned this Jul 22, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request introduces a comprehensive articles API feature with support for listing and retrieving individual articles. The implementation includes filtering, pagination, search capabilities, and proper resource transformation with relationships to categories, tags, and authors.

  • Adds public API endpoints for listing articles with advanced filtering and retrieving single articles by slug
  • Implements robust request validation with default parameters and comprehensive error handling
  • Establishes proper many-to-many relationships between articles, categories, tags, and authors in the data models

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
app/Http/Controllers/Api/V1/Article/GetArticlesController.php Controller for paginated article listing with filtering support
app/Http/Controllers/Api/V1/Article/ShowArticleController.php Controller for retrieving individual articles by slug
app/Http/Requests/Api/V1/Article/GetArticlesRequest.php Request validation class with default parameter handling
app/Http/Resources/Api/V1/Article/ArticleResource.php Resource transformer for consistent article JSON representation
app/Services/ArticleService.php Business logic service for article retrieval and filtering
app/Models/Article.php Added BelongsToMany relationships for categories, tags, and authors
app/Models/Category.php Updated relationship from HasMany to BelongsToMany for articles
app/Models/Tag.php Added BelongsToMany relationship for articles
routes/api_v1.php Added public article API routes and reorganized route grouping
lang/en/common.php Added "Resource not found" localization string
tests/Feature/API/V1/Article/GetArticlesControllerTest.php Comprehensive test coverage for article listing functionality
tests/Feature/API/V1/Article/ShowArticleControllerTest.php Test coverage for single article retrieval

@mubbi mubbi merged commit fa3831e into develop Jul 22, 2025
3 checks passed
@mubbi mubbi deleted the feature/get-articles-api branch July 23, 2025 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants