F
Filament14mo ago
Gush

Adminpanel settings change in App

hello all, i need help understanding how can i dynamicly change a configuration in Adminpanel my example is
->passwordReset() and i want to have a toggle form to change this to either true or false what would be the best approach? Thank you
Solution:
for starters, don't use env() outside of a config file. You'll run into potential caching issues. try this ```php $panel...
Jump to solution
5 Replies
toeknee
toeknee14mo ago
->passwordReset(fn() => run a check / fetch where the setting should come from)
Gush
GushOP14mo ago
i cant do this
->passwordReset(env('ENABLE_PASSWORD_RECOVERY', false))
->passwordReset(env('ENABLE_PASSWORD_RECOVERY', false))
error: UnexpectedValueException PHP 8.2.0 10.37.3 Invalid route action: [1].
Solution
awcodes
awcodes14mo ago
for starters, don't use env() outside of a config file. You'll run into potential caching issues. try this
$panel
->bootUsing(function(Panel $panel) {
if (checkPasswordRecoveryHere) {
$panel->passwordReset();
}
});
$panel
->bootUsing(function(Panel $panel) {
if (checkPasswordRecoveryHere) {
$panel->passwordReset();
}
});
Gush
GushOP14mo ago
thank you for answering
->bootUsing(function (Panel $panel) {
if (config('passwordrecovery.enable_password_recovery')) {
$panel->passwordReset();
}
})
->bootUsing(function (Panel $panel) {
if (config('passwordrecovery.enable_password_recovery')) {
$panel->passwordReset();
}
})
is not working for me error: Route [filament.admin.auth.password-reset.request] not defined.
class AdminPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
if (config('passwordrecovery.enable_password_recovery')) {
$panel->passwordReset();
}
return $panel
->default()
...
class AdminPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
if (config('passwordrecovery.enable_password_recovery')) {
$panel->passwordReset();
}
return $panel
->default()
...
works (for now) 🙃 thank you again
awcodes
awcodes14mo ago
yea, it's too late in the cycle to do what I was recommending. Guess that works too. proper thing would probably be to extend the password classes to add your functionality there.

Did you find this page helpful?