Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/dcasia/nova-detached-actions

A Laravel Nova tool to allow for placing actions in the Nova toolbar detached from the checkbox selection mechanism.
https://github.com/dcasia/nova-detached-actions

actions button laravel nova

Last synced: about 2 months ago
JSON representation

A Laravel Nova tool to allow for placing actions in the Nova toolbar detached from the checkbox selection mechanism.

Awesome Lists containing this project

README

        

# Laravel Nova Detached Actions Tool

A Laravel Nova tool to allow for placing actions in the Nova toolbar, detached from the checkbox selection mechanism.

:warning: Keep in mind, since the action is detached from the row selection checkboxes in the resource table, you will not have a collection of models to iterate over. Detached actions are intended to be independent of the selection in the table.

![screenshot](https://i.imgur.com/S8GrNFI.png)

## Installation

You can install the package in to a Laravel app that uses [Nova](https://nova.laravel.com) via composer:

```bash
composer require digital-creative/nova-detached-actions
```

## Usage

Create a custom Nova Action file:

```bash
php artisan nova:action ExportUsers
```

Instead of extending the `ExportUsers` class with the `Laravel\Nova\Actions\Action` class, swap it with the `DigitalCreative\DetachedActions\DetachedAction` class.

Since we won't receive a collection of `$models`, you can remove the variable from the `handle` method, so that the signature is `public function handle(ActionFields $fields)`.

You can also customize the button label, by overriding the `label()` method. If you do not override the label, it will 'humanize' the class name, in the example `ExportUsers` would become `Export Users`.

Here's a full example:

```php
withHeadings()->askForWriterType()->withMeta([
'detachedAction' => true,
'label' => 'Export'
])->confirmButtonText('Export'),
];
}
...
```

## License

The MIT License (MIT). Please see [License File](LICENSE) for more information.