Remove jsonable feature in favor of Laravel casts#654
Merged
daftspunk merged 5 commits intooctobercms:feature/lean-modelfrom Jan 16, 2026
Merged
Remove jsonable feature in favor of Laravel casts#654daftspunk merged 5 commits intooctobercms:feature/lean-modelfrom
daftspunk merged 5 commits intooctobercms:feature/lean-modelfrom
Conversation
Remove model.beforeGetAttribute, model.getAttribute, model.beforeSetAttribute, and model.setAttribute events from Database and Halcyon models. These events fired on every attribute access/mutation, causing significant overhead (e.g., 50 users × 15 attributes × 2 events = 1,500 event fires for a simple list). Laravel does not fire events for attribute access. Breaking change: Code relying on these events will need refactoring.
Sync getAttribute() with Laravel's implementation by adding an early return for null/empty keys. This prevents unnecessary processing and matches Laravel 12's behavior.
Remove HasJsonable trait entirely and migrate to Laravel's $casts: - Delete HasJsonable.php - Remove trait from Model.php - Remove jsonable handling from HasAttributes (attributesToArray, getAttributeValue, setAttribute) - Remove jsonable handling from Validation trait Migrate models to use $casts with 'array' type: - DeferredBinding: pivot_data - User: permissions - Role: permissions - Preferences: value - ExpandoModel: expandoColumn - contentfield.stub: fieldName Breaking change: $jsonable property no longer supported. Use Laravel's $casts = ['field' => 'array'] instead.
Replace event-based encryption with direct method overrides: - Override setAttribute() to encrypt values before storing - Override getAttributeValue() to decrypt values when reading - Remove bindEvent calls from initializeEncryptable() Mark trait as deprecated in favor of Laravel's 'encrypted' cast: protected $casts = ['secret' => 'encrypted'];
Member
|
Merged to feature branch. Feel free to keep adding to it. Thanks! |
b65593b
into
octobercms:feature/lean-model
0 of 4 checks passed
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.
Remove HasJsonable trait entirely and migrate to Laravel's $casts:
getAttributeValue, setAttribute)
Migrate models to use $casts with 'array' type:
Breaking change: $jsonable property no longer supported.
Use Laravel's $casts = ['field' => 'array'] instead.