Skip to content

withoutGlobalScope #440

Answered by loranger
loranger asked this question in Help
Discussion options

You must be logged in to vote

I did post an issue and get a anwser from @danharrin

The feature is missing and will be added to the next release.

Meanwhile, he told me I was able to override the getQuery method and fetch all my models from the list page

public static function getQuery()
{
    return static::getModel()::query()->withoutGlobalScopes();
}

On the edit page, I also was able to disable the global scopes by overriding the resolveRecord method

protected function resolveRecord($key)
{
    $model = static::getModel();

    $record = $model::withoutGlobalScopes()->findOrFail($key);

    if ($record === null) {
        throw (new ModelNotFoundException())->setModel($model, [$key]);
    }

    return $record;
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by loranger
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
1 participant