do not apply global scope in filament admin (app)
I have a global scope on my User model that is extremely important for 99% of my app that lives outside of the filament admin. I only allow certain users within the admin area. I do want the scope still applied to those same users outside of the admin. With that said, any suggestions for knowing I am within the admin (any resource/page, etc) with filament admin so that i can exclude using that scope during that time? Looking for something rock solid and reliable.
19 Replies
You could remove it inside
Filament::serving()
Any ideas on how to actually unset the globalscope? All docs ive seen are removing it for a query, etc.
Um, good question π
maybe there is a way to not apply it in the first place by identifying in the scope methods apply() if its being called within filament in the first place?
im just nots sure of the reliable way to do that. sure there are some hackish methods, but id rather avoid those and do it right
You'd need to apply it in a middleware then
i mean, the middleware is the same between the two
Yeah, I don't see another way. The array is protected and there is no method to remove it again
I will see if any of the laravel crew in their discord have any ideas or maybe dan will have some ideas if he sees this. I will avoid tagging him though. π
You could suggest PRing it to Laravel π
ok, 2:15am. will pickup it up in the morning. lol
well my attempt at getting ideas in the laravel discord failed miserably. They more just wanted to point out its obviously not global then....
Laravel - The PHP Framework For Web Artisans
Laravel is a PHP web application framework with expressive, elegant syntax. Weβve already laid the foundation β freeing you to create without sweating the small things.
did you not read this far in the docs? π
@Dan Harrin huh? thats per query
Did you not read this far in this thread? π π
yeah in getEloquentQuery() ?
But yeah. Why do you even need to remove it for every request inside the admin panel? π
OR you could apply the global scope in middleware, and only apply it to the non-admin routes
That's what we figured so far.
hmm, though I have a bigger problem anyway as im finding that the when using the impersonate package, its not properly setting the tenant id, so i need to figure that out. thats the biggest use case of filament for this project, that and just basic user management
so i need to see how that is being set and how that would work with transition between the admin portal and client portal. fun stuff i tell you. lol