# Action buttons

## Action Buttons

Action buttons are displayed when browsing a BREAD next to each row

![](https://4207191994-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-ME4uRidwjaTsJKATeNg%2Fsync%2F1c074f46f5eb179655fa6d08e3422c833151e2cf.jpg?generation=1596753421984549\&alt=media)

You can add your own buttons very easily. First we will create an Action-class which extends Voyagers AbstractAction in app/Actions/MyAction.php

```php
<?php

namespace App\Actions;

use TCG\Voyager\Actions\AbstractAction;

class MyAction extends AbstractAction
{
    public function getTitle()
    {
        return 'My Action';
    }

    public function getIcon()
    {
        return 'voyager-eye';
    }

    public function getPolicy()
    {
        return 'read';
    }

    public function getAttributes()
    {
        return [
            'class' => 'btn btn-sm btn-primary pull-right',
        ];
    }

    public function getDefaultRoute()
    {
        return route('my.route');
    }
}
```

Next we need to tell Voyager that we want to use this action. For this open your `app/Providers/AppServiceProvider.php` and search for the `boot()` method

```php
<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Events\Dispatcher;
use TCG\Voyager\Facades\Voyager;

class AppServiceProvider extends ServiceProvider
{
    public function boot()
    {
        Voyager::addAction(\App\Actions\MyAction::class);
    }
}
```

After that you will see your new button when browsing any BREAD ![](https://4207191994-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-ME4uRidwjaTsJKATeNg%2Fsync%2Ff39fc53e233ee6ce85f0e05196481d763a9bafb7.jpg?generation=1596753423217259\&alt=media)

### Showing/hiding actions

If you only want to show your action for special datatypes you can implement a function `shouldActionDisplayOnDataType()` in your action:

```php
<?php

public function shouldActionDisplayOnDataType()
{
    return $this->dataType->slug == 'posts';
}
```

## Mass Actions

Mass actions are called for multiple instances of a model.\
If you want your action to be a mass action, just implement the following method:

```php
<?php

public function massAction($ids, $comingFrom)
{
    // Do something with the IDs
    return redirect($comingFrom);
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://delphinpro.gitbook.io/voyager-ru/customization/action-buttons.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
