Getting started
Library
Components
Integrations
Bulk actions
The Media Library allows you to run bulk actions on selected items from the Media Library. By default, the Media Library comes with several bulk actions which you can expand with your own custom bulk actions.
Custom actions
You can provide custom bulk actions using the ->bulkActions() method:
use RalphJSmit\Filament\Explore;
$plugin
->bulkActions([
Explore\Filament\Actions\MoveBulkAction::make(),
Explore\Filament\Actions\DeleteBulkAction::make(),
Explore\Filament\Actions\BulkAction::make('optimize')
->icon(Heroicon::OutlinedSparkles)
->action(function (Collection $files) {
// Perform an action...
}),
ActionGroup::make([
Explore\Filament\Actions\CreateFolderBulkAction::make(),
])
->icon(Heroicon::OutlinedEllipsisHorizontal)
->color('gray'),
]);
For optimum flexibiity, the provided bulk actions will replace the default set of bulk actions. Therefore, you can reference the pre-built actions already provided for you to build your own custom layout to your liking.
Your bulk actions should also extend the RalphJSmit\Filament\Explore\Filament\Actions\BulkAction class. This class is responsibile for correctly turning the action argument into an injected Collection $files instance for you to use.
Appending actions
If you only want to add actions without replacing the defaults, you can use the push variants. These are available on the driver:
use RalphJSmit\Filament\Explore\Filament\Actions;
$driver
->pushBulkActions([
Actions\BulkAction::make('optimize')
->icon(Heroicon::OutlinedSparkles)
->action(function (Collection $files) {
// ...
}),
])
->pushFileActions([
Actions\Action::make('analyze')
->icon(Heroicon::OutlinedMagnifyingGlass)
->action(function (FileData $file) {
// ...
}),
])
->pushFileInfoActions([
Actions\Action::make('share')
->icon(Heroicon::OutlinedShare)
->action(function (FileData $file) {
// ...
}),
])
->pushEmptyStateActions([
Actions\Action::make('import')
->action(function () {
// ...
}),
]);
The push variants append your actions to the default set, while ->bulkActions(), ->fileActions(), ->fileInfoActions() and ->emptyStateActions() replace all defaults entirely.
Empty state actions
You can customize the actions shown when a folder is empty using the ->emptyStateActions() method on the driver. By default, an upload action is shown:
use RalphJSmit\Filament\Explore\Filament\Actions;
$driver->emptyStateActions([
Actions\UploadAction::make(),
Actions\Action::make('import')
->label('Import from external source')
->action(function () {
// ...
}),
])