Skip to content

Conversation

zigzagdev
Copy link
Owner

Description

This PR merges the pagination implementation into the show-post-index feature branch.

The merged changes include:

  • Pagination DTO in the application layer for encapsulating paginated data and metadata
  • PaginationFactory for constructing the DTO from Laravel paginator array
  • Pagination ViewModel and corresponding ViewModelFactory for formatting the pagination structure in the presentation layer
  • toArray() response structure standardised with data and pagination keys
  • Preparation for consistent API response handling in post index view

…tion-dto

Implement Pagination DTO and factory for application-layer pagination handling
…tion-viewmodel

Implement Pagination ViewModel and factory for presentation-layer formatting
@zigzagdev zigzagdev requested a review from Copilot June 11, 2025 00:56
@zigzagdev zigzagdev self-assigned this Jun 11, 2025
@zigzagdev zigzagdev added enhancement New feature or request backend labels Jun 11, 2025
@zigzagdev zigzagdev linked an issue Jun 11, 2025 that may be closed by this pull request
Copy link
Owner Author

@zigzagdev zigzagdev left a comment

Choose a reason for hiding this comment

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

Self review

  • Pagination logic is kept out of domain layer as intended
  • Presentation layer prepares a clean API response structure via ViewModel
  • Factory patterns prevent duplication and centralise transformation logic
  • show-post-index remains focused on fetching and displaying data, now powered by structured pagination
  • No breaking changes introduced to existing application contracts

@zigzagdev zigzagdev merged commit fc8ab58 into feature/show-post-index Jun 11, 2025
Copy link

@Copilot 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 PR integrates pagination functionality into the post index view by introducing new DTO, ViewModel, factories, and accompanying tests.

  • Introduces a Pagination DTO and a corresponding ViewModel
  • Implements factory classes to create DTOs and ViewModels from paginated data
  • Adds tests to verify DTO and ViewModel behavior

Reviewed Changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/app/Common/Presentation/ViewModelFactory/PaginationFactory.php Creates a ViewModel from the Pagination DTO and data array
src/app/Common/Presentation/ViewModel/Pagination.php Defines the Pagination ViewModel with a toArray() method
src/app/Common/Presentation/PresentationTest/PaginationViewModelTest.php Tests the Pagination ViewModel, including type and value checks
src/app/Common/Application/DtoFactory/PaginationFactory.php Builds the Pagination DTO from the provided array data
src/app/Common/Application/Dto/Pagination.php Implements the Pagination DTO with accessor methods and toArray()
src/app/Common/Application/ApplicationTest/PaginationDtoTest.php Verifies the Pagination DTO’s type and value assignment
Files not reviewed (1)
  • .idea/workspace.xml: Language not supported
Comments suppressed due to low confidence (1)

src/app/Common/Presentation/PresentationTest/PaginationViewModelTest.php:127

  • The test iterates over expected keys and checks for corresponding getter methods, yet the Pagination view model does not implement any getters. Consider adding explicit getters or updating the test to validate the output of toArray() to strengthen test coverage.
if (method_exists($viewModel, $getter)) {

Comment on lines +12 to +13
private ?string $from = null,
private ?string $to = null,
Copy link

Copilot AI Jun 11, 2025

Choose a reason for hiding this comment

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

The 'from' property is declared as a nullable string, but the view model expects an integer. Consider changing its type to int (and likewise for 'to') to ensure consistency across layers.

Suggested change
private ?string $from = null,
private ?string $to = null,
private ?int $from = null,
private ?int $to = null,

Copilot uses AI. Check for mistakes.

@zigzagdev zigzagdev deleted the feature/show-post-index-pagination branch June 11, 2025 00:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Pagination Structure

1 participant