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 model scopes ignored in HasManyDeep #35

Closed
brynj-digital opened this issue Jul 24, 2019 · 5 comments
Closed

Global model scopes ignored in HasManyDeep #35

brynj-digital opened this issue Jul 24, 2019 · 5 comments

Comments

@brynj-digital
Copy link

I have global scopes that are applied in the boot() method of some of my models in a HasManyDeep relationship.

It seems like these are being ignored - in effect, I'm getting data that I shouldn't be because my model 'active' property is being ignored.

Is this expected behaviour, or should global scopes apply in intermediate models?

@staudenmeir
Copy link
Owner

staudenmeir commented Jul 24, 2019

It's not ideal, but it's the expected behavior. Of the intermediate models' global scopes, only SoftDeletes is applied automatically. I chose this behavior to match Laravel's native HasManyThrough relationship (laravel/framework#23039 (comment)).

You'll need to apply these global scopes manually.

@brynj-digital
Copy link
Author

Thank you for the prompt reply and clarification - it's useful to confirm it as expected behaviour, and I will ensure I deal with these instances appropriately.

@LonnyX
Copy link

LonnyX commented Nov 9, 2019

@staudenmeir is it normal that withTrashed() doesn't works on this case?
I understand that SoftDeletes is applied automatically but how can we prevent this?

@staudenmeir
Copy link
Owner

@LonnyX
Copy link

LonnyX commented Nov 9, 2019

Oops, I commented on the wrong rep, sorry.
Thank you for this package.
I wonder why this is still not fixed by Laravel :/

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

No branches or pull requests

3 participants