Skip to content

Add methods to navigate revisions: next, isFirstRevision, and isLastR… - #17

Merged
thijskok merged 2 commits into
mainfrom
added-first-last-revision
Jul 9, 2026
Merged

Add methods to navigate revisions: next, isFirstRevision, and isLastR…#17
thijskok merged 2 commits into
mainfrom
added-first-last-revision

Conversation

@thijskok

@thijskok thijskok commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

…evision

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 adds revision-navigation helpers to the Revision model and introduces a dedicated test suite to validate navigating between adjacent revisions and detecting boundary revisions.

Changes:

  • Adds next() to fetch the immediate subsequent revision for the same revisionable model.
  • Adds isFirstRevision() / isLastRevision() convenience helpers on Revision.
  • Adds RevisionNavigationTest coverage for previous(), next(), and first/last detection.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
tests/RevisionNavigationTest.php Adds unit tests validating previous/next navigation and first/last revision checks.
src/Models/Revision.php Implements next(), isFirstRevision(), and isLastRevision() on the Revision model.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Models/Revision.php
Comment on lines +189 to +193
/**
* Return the revision that directly follows this one for the same model.
*/
public function next(): ?static
{
Comment thread src/Models/Revision.php
Comment on lines +207 to +210
public function isFirstRevision(): bool
{
return $this->getKey() === $this->revisionable->revisions->min($this->getKeyName());
}
Comment thread src/Models/Revision.php
Comment on lines +215 to +218
public function isLastRevision(): bool
{
return $this->getKey() === $this->revisionable->revisions->max($this->getKeyName());
}
@thijskok
thijskok requested review from Frankisgek and stefanius July 9, 2026 15:53
@thijskok
thijskok requested a review from stefanius July 9, 2026 16:37
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

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

Comment thread src/Contracts/Revision.php
@thijskok
thijskok requested a review from Copilot July 9, 2026 18:22
@thijskok
thijskok merged commit 1e14909 into main Jul 9, 2026
8 checks passed
@thijskok
thijskok deleted the added-first-last-revision branch July 9, 2026 18:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

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

Comment on lines 16 to 22
public function previous(): ?static;

public function next(): ?static;

public function diff(?self $target = null): Diff;

public function toModel(): Model;
Comment on lines 16 to +19
public function previous(): ?static;

public function next(): ?static;

Comment thread src/Models/Revision.php
Comment on lines +207 to +218
public function isFirstRevision(): bool
{
return $this->exists && $this->previous() === null;
}

/**
* Determine whether this is the most recent revision for its model.
*/
public function isLastRevision(): bool
{
return $this->exists && $this->next() === null;
}
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.

4 participants