CRUD icon indicating copy to clipboard operation
CRUD copied to clipboard

withoutGlobalScopes does not work in setupShowOperation

Open AlexKomMsk opened this issue 2 years ago • 3 comments

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

AlexKomMsk avatar Feb 21 '23 23:02 AlexKomMsk

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 avatar Feb 22 '23 17:02 pxpm

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.

tabacitu avatar Apr 29 '23 10:04 tabacitu

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.

AlexKomMsk avatar Jul 02 '23 14:07 AlexKomMsk