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

Disable global scopes #442

Closed
loranger opened this issue Jun 7, 2021 · 2 comments
Closed

Disable global scopes #442

loranger opened this issue Jun 7, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@loranger
Copy link

loranger commented Jun 7, 2021

Describe the bug
Admin should return all models, including those filtered with the binded scopes on the model and let administrator filter the models with the filament filter feature

To reproduce
Steps to reproduce the behavior:

  1. Add a global scope on a model
  2. Only eligible models are shown in filament
  3. Add a filter in order to force them to display
  4. Model is listed in the table
  5. Model edition throws a 404

Expected behavior
All models are displayed and are editable

Context

  • Package version: 1.10
  • Laravel version: 8.12
  • Browser: Firefos
  • Server OS: Debian 10
  • PHP version: 7.4
  • Database: MariaDB 10.5

Additional details
Maybe there's already a solution, but I can't find any clue in the documentation, nor in the discussions

@loranger loranger added bug Something isn't working unconfirmed labels Jun 7, 2021
@danharrin
Copy link
Member

Hey, I will add disabling global scopes to the list of features for v2. In the meantime, you can override certain methods on page classes to implement this behaviour yourself.

On list pages, you can override the static getQuery() method to query the model without global scopes. https://github.com/laravel-filament/filament/blob/main/src/Resources/Pages/Page.php#L20-L23

On edit pages, you can override the resolveRecord() method to query the model without global scopes, using the key parameter. https://github.com/laravel-filament/filament/blob/main/src/Resources/Pages/EditRecord.php#L123-L134

@danharrin danharrin added enhancement New feature or request and removed bug Something isn't working unconfirmed labels Jun 7, 2021
@loranger
Copy link
Author

loranger commented Jun 8, 2021

Thank you !

I was able to make it work.
In my humble opinion, a more detailed documentation could help us to find solutions without disturbing you.

Anyway thank you so much for your support and this awesome package 👍🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants