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

withoutGlobalScopes does not work in setupShowOperation #4935

Open
AlexKomMsk opened this issue Feb 21, 2023 · 3 comments
Open

withoutGlobalScopes does not work in setupShowOperation #4935

AlexKomMsk opened this issue Feb 21, 2023 · 3 comments

Comments

@AlexKomMsk
Copy link

Bug report

What I did

open setupShowOperation

make

$this->crud->query = $this->crud->query->withoutGlobalScopes();

and i get 404 error.

It works in setupListOperation.

What I expected to happen

I want to get a model in the admin without soft-deleted and without global scopes.

What happened

404

Backpack, Laravel, PHP, DB version

When I run php artisan backpack:version the output is:

LARAVEL VERSION:

v9.52.0@eb85cd9d72e5bfa54b4d0d9040786f26d6184a9e

BACKPACK PACKAGE VERSIONS:

backpack/crud: 5.5.0
backpack/generators: 3.3.14

@pxpm
Copy link
Contributor

pxpm commented Feb 22, 2023

Hello @AlexKomMsk

We had for years documented the usage of $this->crud->query as a way to manipulate the underlying panel query. That was a wrong thing to do!

We shouldn't have done it in the first place, we have the ->addClause() and addBaseClause() functions, and those are the ones that should be used to manipulated the query.

You should be able to solve your issue with $this->crud->addClause('withoutGlobalScopes');

However I can confirm there is an issue with show operation, since it uses a different approach than ListOperation. (But they should use the same, I agree).

I am working on a fix (actually I had this fixed in a PR not related to showOperation), so I will just split that bit out of that PR and create a new one, only to address this issue.

Cheers

@pxpm pxpm added Bug and removed triage labels Feb 22, 2023
@pxpm pxpm self-assigned this Feb 22, 2023
@pxpm pxpm moved this to In Progress in This week Feb 22, 2023
@tabacitu tabacitu moved this to Todo in Backpack v5.4+ Apr 29, 2023
@tabacitu tabacitu moved this from Todo to In Progress in Backpack v5.4+ Apr 29, 2023
@tabacitu
Copy link
Member

tabacitu commented Apr 29, 2023

Pedro, perhaps you can offload this to Jorge and Karan? Their mission is to fix as many small things they can in 5.4 now.

@AlexKomMsk
Copy link
Author

It seems to me that it is better to turn off global scopes in the config. Global scopes in the admin panel are almost always unnecessary and get in the way.

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

No branches or pull requests

3 participants