Skip to content

Conversation

@emargareten
Copy link
Contributor

This PR is similar to my previous PR, but for global scopes. It adds an option to register global scopes via an attribute.

For example:

#[ScopedBy(AncientScope::class)]
class User extends Model
{
    //
}

It's also possible to use an array of scope classes:

#[ScopedBy([FirstScope::class, SecondScope::class])]

This makes it easier to see which global scopes are applied to a model rather than having to look through the boot method.

@taylorotwell taylorotwell merged commit 67a0e47 into laravel:10.x Feb 9, 2024
Bakke pushed a commit to Bakke/framework that referenced this pull request Feb 11, 2024
* [10.x] Introduce ScopedBy attribute for models

* Update HasGlobalScopes.php
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.

2 participants