Roy
Roy
FFilament
Created by Roy on 9/26/2024 in #❓┊help
Revert togglecolumn $state if condition unsatisfied.
can you confirm on your side it is same behaviour as well? is this consider an issue to be submitted on github?
15 replies
FFilament
Created by Roy on 9/26/2024 in #❓┊help
Revert togglecolumn $state if condition unsatisfied.
and I want to run notification as well. if disabled, can we set notification like below? I think it would become more complex isnt it?

ToggleColumn::make( 'confirmed' )
->label( 'Confirmed' )
->updateStateUsing( function ($record, $state): bool {
$user = auth()->user();

if ($user->hasRole( 'admin' )) {
return $state; // Confirm toggle on success
} else {
Notification::make()
->title( 'Action Blocked' )
->body( 'You do not have permission to change this status.' )
->color( 'danger' )
->warning()
->send();
throw ValidationException::withMessages( [] );
}

} ),

ToggleColumn::make( 'confirmed' )
->label( 'Confirmed' )
->updateStateUsing( function ($record, $state): bool {
$user = auth()->user();

if ($user->hasRole( 'admin' )) {
return $state; // Confirm toggle on success
} else {
Notification::make()
->title( 'Action Blocked' )
->body( 'You do not have permission to change this status.' )
->color( 'danger' )
->warning()
->send();
throw ValidationException::withMessages( [] );
}

} ),
15 replies
FFilament
Created by Roy on 9/26/2024 in #❓┊help
Revert togglecolumn $state if condition unsatisfied.
because the above code able to prevent toggle from false to true, but not able to prevent the opposite.
15 replies
FFilament
Created by Roy on 9/26/2024 in #❓┊help
Revert togglecolumn $state if condition unsatisfied.
is disabled a better choice in this case?
15 replies
FFilament
Created by Roy on 9/26/2024 in #❓┊help
Revert togglecolumn $state if condition unsatisfied.
yes, and other condition as well. not necessary non-admins
15 replies
FFilament
Created by S.V Gubadov on 9/25/2024 in #❓┊help
Svg by name "filament-shield::filament-shield.nav.role.icon" from set "default" not found.
Maybe can try to publish the translation
4 replies