-
Notifications
You must be signed in to change notification settings - Fork 897
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
Show operation addClause ignoring for SoftDeletes #5204
Comments
Hello there! Thanks for opening your first issue on this repo! Just a heads-up: Here at Backpack we use Github Issues only for tracking bugs. Talk about new features is also acceptable. This helps a lot in keeping our focus on improving Backpack. If you issue is not a bug/feature, please help us out by closing the issue yourself and posting in the appropriate medium (see below). If you're not sure where it fits, it's ok, a community member will probably reply to help you with that. Backpack communication channels:
Please keep in mind Backpack offers no official / paid support. Whatever help you receive here, on Gitter, Slack or Stackoverflow is thanks to our awesome awesome community members, who give up some of their time to help their peers. If you want to join our community, just start pitching in. We take pride in being a welcoming bunch. Thank you! -- |
Hi @skater4 , Indeed, the default behaviour is that... if SoftDeletes is present on the Model, the Show operation WILL show that entry and add a You can change that behaviour in the config file for that operation. Just go to // If model has SoftDeletes, allow the admin to access the Show page for
// soft deleted items & add a deleted_at column to ShowOperation?
'softDeletes' => false, Let me know if that doesn't work for you. Cheers! |
i think u didnt understand me. soft deletes are ok, BUTTT |
Oh ok I think I understand now. Let me rephrase: In your That's true, ShowOperation doesn't use the same general // instead of this
$this->crud->addClause('whereIn', 'feed_id', [10,20]);
// you should do something like this
$this->crud->operation(['show', 'update'], function() {
$id = $this->crud->getCurrentEntryId();
// TODO: now check that the ID is allowed to be updated/edited, otherwise abort
}); I do not recommend editing something general like the query in The question now becomes... and I'm asking you @pxpm ... SHOULD WE change how we get the current entry... in order to use |
Thank you for reply. |
So what do you recommend we do @pxpm ? |
so it decided like unimportant? because i was surprised when SoftDeletes affected other logic that doesnt matches SoftDeletes |
At the moment can't do much, as it's clearly a breaking change. That PR came in a bad time and we didn't spent time trying to weight the cons/pros. And I didn't do a great job making my case. I think that's also because I know it's a HUGE change, and it needs a crime partner 👯♂️ For example one of the reasons I identified that we use the model directly instead of the query it's because the translatable package overwrites the
When making the call to - $this->data['entry'] = $this->crud->getModel()->withTrashed()->findOrFail($id);
+ $this->data['entry'] = $this->crud->query->withTrashed()->findOrFail($id);
+ $this->data['entry'] = $this->crud->setLocaleOnModel($this->data['entry']); As far as I am aware that was the only reason for that. Can I be wrong? Yes. People doing We can do this change specifically here in ShowOperation
I think this is the line that does not respect the query. Is it a BC ? We may consider it yes, but it's not that huge PR 🤷 |
Maybe u make some fix with backward compatibility? Possible defining deprecated old functionality |
Yes, usePanelQuery parameter would be good for now. But any case SoftDeletes behavior still confusing and non logical |
Bug report
What I did
any crud controller, setup method
$this->crud->addClause('whereIn', 'feed_id', [1,2,3]);
(any condition)What I expected to happen
show operation should return 404 if current entity doesnt have feed_id in 1,2,3
What happened
if model has SoftDeletes - it return entity page
Is it a bug in the latest version of Backpack?
5.6.1
After I run
composer update backpack/crud
the bug... is it still there?Yes
Backpack, Laravel, PHP, DB version
When I run
php artisan backpack:version
the output is:PHP VERSION:
PHP 8.2.6 (cli) (built: May 23 2023 09:42:25) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.6, Copyright (c) Zend Technologies
LARAVEL VERSION:
v9.39.0@67e674709e1e7db14f304a871481f310822d68c5
BACKPACK PACKAGE VERSIONS:
backpack/crud: 5.6.1
backpack/generators: 3.3.16
backpack/permissionmanager: 6.0.17
The text was updated successfully, but these errors were encountered: