-
Notifications
You must be signed in to change notification settings - Fork 17
Description
Hi,
Thanks for this plugin, i currently have an issue with multi tenancy and global scopes as the .
For instance in the multi tenant mode i have a middleware that apply a global scope in order to prevent ajax requests to fetch other users in the select.
And when i want to switch to a different user from another entity i get a 404 because i'm still in the current entity
The workaround I've found is to add directly the withoutGlobalScope in src/FilamentDevelopersLogin.php
$model = (new ($plugin->getModelClass()))
->withoutGlobalScope('user_team') // <--- here
->where($plugin->getColumn(), $credentials)
->first();
But maybe some people will have another issue with this.
I don't know if a good way is to allow to add custom query builder clauses alongside the already present where($plugin->getColumn(), $credentials)
or to make something that can replace it entirely.
With something like $plugin->getModelQuery() and in the PanelProvider use it like that
FilamentDeveloperLoginsPlugin::make()
->users(fn() => User::withoutGlobalScope('user_team')->pluck('email', 'name')->toArray())
->getModelQuery(fn(Builder $query) => $query->withoutGlobalScope('user_team')) // <--- here
->enabled(app()->environment('local'))
What do you think ?
Thanks,
Alex