You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/upgrading.md
+13-26Lines changed: 13 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -96,50 +96,37 @@ InspireCMS v4 supports both Laravel 12 and Laravel 13.
96
96
97
97
### What changed
98
98
99
-
To avoid Laravel 13 model boot recursion errors (for example: `bootIfNotBooted` called while a model is still booting), model observer registration was centralized in service providers.
99
+
To avoid Laravel 13 model boot recursion errors (for example: `bootIfNotBooted` called while a model is still booting), observer registration was changed from using `Model::observe()` to direct event listener registration within trait boot methods.
100
100
101
-
Observer registration now happens in:
101
+
Event listeners are now registered directly in trait boot methods instead of using `Model::observe()`.
If you override model classes via InspireCMS config/model manifest, keep observer registration in the provider layer. Avoid registering observers inside model `boot()`, `booted()`, or trait boot methods for the same model.
105
+
When using traits that register observers, register event listeners directly in the trait's boot method instead of using `Model::observe()`.
static::created(fn ($model) => (new YourObserver)->created($model));
124
+
static::updated(fn ($model) => (new YourObserver)->updated($model));
125
+
static::deleted(fn ($model) => (new YourObserver)->deleted($model));
127
126
}
128
127
```
129
128
130
-
If your custom model uses traits that previously registered observers in trait boot methods, move those observer registrations to the same provider method as well.
131
-
132
-
### Recommended dependency constraints
133
-
134
-
Use composer constraints that allow both versions:
135
-
136
-
```json
137
-
"laravel/framework": "^12.0|^13.0"
138
-
```
139
-
140
-
### Recommended CI matrix
141
-
142
-
Run your package test suite against both Laravel versions, ideally with both lowest and stable dependency sets, to catch compatibility regressions early.
129
+
If your model has multiple trait-boot observers, register each trait's listeners separately in its own boot method.
0 commit comments