Can we use the Scope attribute with Laravel 13 #87

Open
opened 2026-04-04 19:47:39 +02:00 by jonny · 0 comments
Owner

This didn’t work as expected when upgrading to Laravel 13, Claude gave the feedback:

#[Scope] was reverted — It turns out the attribute only works when you already have a query builder instance (e.g. Note::query()->nb60(...)). The static shorthand Note::nb60(...) that your codebase uses works via __callStatic, which is only invoked when PHP can't find a matching method name — but adding an instance method nb60() means PHP finds it and tries to call it statically, causing a fatal error. The scope* prefix convention keeps working because there's no date() / nb60() instance method, so __callStatic intercepts correctly.

This didn’t work as expected when upgrading to Laravel 13, Claude gave the feedback: > `#[Scope]` was reverted — It turns out the attribute only works when you already have a query builder instance (e.g. `Note::query()->nb60(...)`). The static shorthand `Note::nb60(...)` that your codebase uses works via `__callStatic`, which is only invoked when PHP can't find a matching method name — but adding an instance method `nb60()` means PHP finds it and tries to call it statically, causing a fatal error. The `scope*` prefix convention keeps working because there's no `date()` / `nb60()` instance method, so `__callStatic` intercepts correctly.
jonny changed title from Can we sue the Scope attribute with Laravel 13 to Can we use the Scope attribute with Laravel 13 2026-04-07 10:20:04 +02:00
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
jonny/jonnybarnes.uk#87
No description provided.