Skip to content

Add Laravel 13 support#123

Open
pktharindu wants to merge 3 commits into
kirkbushell:masterfrom
pktharindu:laravel-13
Open

Add Laravel 13 support#123
pktharindu wants to merge 3 commits into
kirkbushell:masterfrom
pktharindu:laravel-13

Conversation

@pktharindu
Copy link
Copy Markdown

@pktharindu pktharindu commented Apr 28, 2026

Adds ^13.0 to the illuminate/* constraints, branched from 12.0.1.

While testing against a Laravel 13 app I hit Laravel 13's new boot guard: Model::observe() calls new static, and constructing a model while it's still booting now throws a LogicException. So static::observe(Observer::class) from a trait boot method blows up.

Switched HasCounts, HasSums, and HasValues to register the listeners directly via static::created/updated/deleted/restored with Class@method strings — same as what registerObserver() does internally, just without the new static. The restored listener now only registers when SoftDeletes is on the model, otherwise Laravel complains the event isn't observable.

Tested with the count/sum/value cache traits in a real L13 app; observers fire as before.

Laravel 13 hardened Model::bootIfNotBooted to throw a LogicException
when a new instance of a model is constructed while that model is
itself booting. Model::observe() instantiates the model via
new static, so calling static::observe(Observer::class) from a
trait boot method now triggers re-entrant booting and breaks
applications upgrading to Laravel 13.

Register the observer's individual event listeners directly via
static::created/updated/deleted/restored using class@method strings
instead, which avoids constructing the model and matches the dispatch
pattern Laravel uses internally in registerObserver().
@pktharindu
Copy link
Copy Markdown
Author

@kirkbushell could you review this when you have a second?

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.

1 participant