F
Filamentβ€’12mo 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
toekneeβ€’12mo ago
->passwordReset(fn() => run a check / fetch where the setting should come from)
Gush
GushOPβ€’12mo 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
awcodesβ€’12mo 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
GushOPβ€’12mo 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
awcodesβ€’12mo 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.
Want results from more Discord servers?
Add your server