CRUD
CRUD copied to clipboard
withoutGlobalScopes does not work in setupShowOperation
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
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
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.
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.