Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global scopes are not serialized #3

Closed
joelclermont opened this issue Oct 24, 2020 · 1 comment
Closed

Global scopes are not serialized #3

joelclermont opened this issue Oct 24, 2020 · 1 comment

Comments

@joelclermont
Copy link

  • Package Version: 0.2.1
  • Laravel Version: 8.2.0
  • PHP Version: 7.4.11

Description:

When a model attaches a global query scope on booted that is not serialized.

Steps To Reproduce:

Add this to a model:

protected static function booted()
{
    static::addGlobalScope('id', function (Builder $builder) {
        $builder->where('id', '<', 10);
    });
}

Create a basic query for that model and serialize it, then unserialize it. The unserialized query will not have the global scope applied.

On the other hand if we do this as a local scope, it works as expected:

public function scopeHasSingleDigitId($query)
{
    return $query->where('id', '<', 10);
}
@crynobone
Copy link
Member

Thank you for the report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants