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

Callback parameter when checking or fixing the tree #536

Open
wants to merge 2 commits into
base: v6
Choose a base branch
from

Conversation

G3z
Copy link

@G3z G3z commented Sep 29, 2021

I've added an optional callback to fixTree() countErrors() and relative methods so a user can configure the query

My main use case i to disable global scopes (I've added tests for this use case)

usage

Category::fixTree(function($query){
  $query->withoutGlobalScopes([AnUnwantedScope::class]);
});

Category::isBroken(function($query){
  $query->withoutGlobalScopes([AnUnwantedScope::class]);
});

@jonnott
Copy link
Contributor

jonnott commented Mar 8, 2024

@lazychaser It would be great if you could merge one of these PRs (there are a few similar), basically so global scopes are removed (or can be removed) when calling isBroken() or fixTree().

Often global scopes are used for tenanting or other purposes, but when checking or fixing the tree, we want to treat the entire table as one whole, and fix lft and rgt values across all entries in the table.

Having an optional query scope passed in, as in this PR, seems like a good approach, as then there's no breaking change to the current default behaviour of the methods.

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