<?php
namespace App\Filament\Resources\UserResource\Pages;
use App\Filament\Resources\UserResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
class ListUsers extends ListRecords
{
protected static string $resource = UserResource::class;
protected function getTableActions(): array
{
return [
Actions\Action::make('resetPassword')
->label('Reset password')
->icon('heroicon-o-exclamation-triangle')
->color('warning')
->requiresConfirmation()
->modalIcon('heroicon-o-exclamation-triangle')
->modalIconColor('warning')
->modalHeading('Reset password')
->modalDescription('Are you sure you want to reset this user's password?')
->modalSubmitActionLabel('Confirm')
->modalCancelActionLabel('Cancel')
->modalActions([
Actions\Action::make('submit')
->label('Confirm')
->color('warning') // Here we set the color of the confirm button
->submit(),
Actions\Action::make('cancel')
->label('Cancel')
->color('gray') // The cancel button color
->cancel(),
])
->action(function ($record): void {
// Here you can perform your reset logic for the specific user
$record->update(['password' => bcrypt('new-password')]);
// Optionally, send a notification
// Notification::make()
// ->title('Password for ' . $record->name . ' has been reset.')
// ->success()
// ->send();
}),
];
}
}
try this