How do I create a custom bulk action?
You can create a class that extends \Aero\Admin\BulkActions\BulkActionJob and implement a handle method:
class DeleteProductsBulkAction extends \Aero\Admin\BulkActions\BulkActionJob
implements \Illuminate\Contracts\Queue\ShouldQueue
{
protected $list;
public function __construct(\Aero\Admin\ResourceLists\ProductsResourceList $list)
{
$this->list = $list;
}
public function handle(): void
{
$this->list->items()->each(static function (\Aero\Catalog\Models\Product $product) {
$product->delete();
event(new \Aero\Catalog\Events\ProductDeleted($product));
});
}
}
You should implement \Illuminate\Contracts\Queue\ShouldQueue if you want the bulk action to be queued.