Upgrade to Laravel 12 and PHP 8.5, remove deprecated registerData#35
Open
Upgrade to Laravel 12 and PHP 8.5, remove deprecated registerData#35
Conversation
mooya
approved these changes
Jan 16, 2026
brdv
requested changes
Jan 29, 2026
Member
brdv
left a comment
There was a problem hiding this comment.
If you read the tests correctly, you see that half the models/attributes are for register() tests and the other half are for to{*} resource tests.
You've now changed all register() resource to use the 'new' methods. This is unneeded, since that's already tested in the other resources. So the old register() using resources can be removed and their tests as well. Just double check that all functionality is still tested, but ONLY for the original to{*} tests.
BREAKING CHANGES: - Require PHP 8.5+ (was 8.2+) - Require Laravel 12+ (was 8-11) - Remove deprecated register() method and registerData property - Change toAttributes() visibility to public (Laravel 12 compatibility) - Add resolveResourceData() override to prevent circular dependency Changes: - Updated composer.json dependencies for Laravel 12 and PHP 8.5 - Fixed Laravel 12 compatibility by overriding resolveResourceData() - Changed toAttributes() from protected to public in all resources - Removed registerData property and register() method from JsonApiResource - Converted test resources from register() to method-based approach - Updated documentation to reflect method-based definitions only Migration Guide: 1. Upgrade to PHP 8.5+ and Laravel 12+ 2. Change all 'protected function toAttributes()' to 'public function toAttributes()' 3. Convert any register() methods to toId(), toAttributes(), toRelationships(), toMeta(), toLinks() All tests passing (49 tests, 85 assertions)
- Set php_version to 8.5 for composer and PHPUnit actions - Update PHPUnit version from 9.6 to 11
dba2303 to
eec731c
Compare
brdv
approved these changes
Feb 6, 2026
pint action 2.0.0 does not have the onlyDirty option yet, later v2 does.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🚀 Major Version Upgrade
This PR upgrades the package to Laravel 12 and PHP 8.5, and removes the deprecated
registerDatafunctionality.1. Minimum Requirements
2. Removed Deprecated Functionality
register()methodregisterDataproperty3. Method Visibility Change
toAttributes()is now public (was protected) for Laravel 12 compatibility📝 Changes Made
Dependencies Updated
^8.2→^8.5^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0→^12.0^7.22.0→^10.0^9.6.3→^11.0Laravel 12 Compatibility Fixes
resolveResourceData()override to prevent circular dependency betweentoArray()andtoAttributes()toAttributes()visibility fromprotectedtopublicto match Laravel 12's baseJsonResourceclasstoAttributes()and how it differs from Laravel's implementationRemoved Deprecated Code
private array $registerDatapropertyprotected function register(): arraymethodregisterDataingetType(),toAttributes(),toRelationships(),toMeta(),toLinks()Test Resources Converted
All test resources converted from
register()to method-based approach:AccountResource.phpPostResource.phpCommentResource.php🧪 Testing
All tests passing:
📖 Migration Guide for Users
Step 1: Update Requirements
Step 2: Change Method Visibility
Change all
protected function toAttributes()topublic function toAttributes():Step 3: Convert register() to Method-Based Definitions
Before (deprecated):
After (required):
🔍 Technical Details
Why Override
toAttributes()?Laravel 12's
toAttributes()returns the full resource (same astoArray()), but JSON:API needs it to return only the attributes portion:Laravel's behavior:
JSON:API behavior:
This override is intentional and necessary to:
📌 Notes