---
title: Actions
published: 2026-10-19
lastmod: 2026-10-19
url: https://larasell.dev/docs/admin/reference/actions
---

## Table of contents
- [Creating actions](#creating-actions)
- [Icons](#icons)
- [Link actions](#link-actions)
- [Destructive actions](#destructive-actions)
- [Confirmation](#confirmation)
  - [Customising the confirmation dialog](#customising-the-confirmation-dialog)
  - [Type to confirm](#type-to-confirm)
- [Disabling actions](#disabling-actions)
- [Hiding actions](#hiding-actions)

# Actions

An `Action`{href="https://raw.githubusercontent.com/Larasell-dev/admin/refs/heads/main/src/Tables/Actions/Action.php"} allows you to add features to a table, like viewing, editing or deleting
a row. Anything you can do with PHP you can do with actions. They appear on the right side of the
table, tucked behind a dropdown menu.

## Creating actions

Add actions by overriding the `actions`{href="https://raw.githubusercontent.com/Larasell-dev/admin/refs/heads/main/src/Tables/Table.php"} method of a table:

```php
namespace App\Tables;

use App\Models\ProductReview;
use Larasell\Admin\Tables\Actions\Action;
use Larasell\Admin\Tables\Table;

class ProductReviewTable extends Table
{
    public function actions(): array
    {
        return [
            Action::make('Publish', fn (ProductReview $record) => $record->publish()),
        ];
    }
}
```

When a user clicks the action, the code runs for that row.

## Icons

Add an icon to an action with the `icon` method. It accepts an `Icon`{href="https://raw.githubusercontent.com/Larasell-dev/admin/refs/heads/main/src/Enums/Icon.php"} enum case or a [Remix icon](https://remixicon.com) name:

```php
use Larasell\Admin\Enums\Icon;

public function actions(): array
{
    return [
        Action::make('Publish', fn (ProductReview $record) => $record->publish())
            ->icon(Icon::UploadCloud2),

        // The Remix icon name also works as a string
        Action::make('Delete', fn (ProductReview $record) => $record->delete())
            ->icon('delete-bin'),
    ];
}
```

## Link actions

The `route`{href="https://raw.githubusercontent.com/Larasell-dev/admin/refs/heads/main/src/Tables/Actions/Action.php"} method turns the action into a link to a named route.
When a user clicks it, the link takes them to that page. Without parameters, the record becomes
the route parameter. Use it to link to the create or edit page of a model.

```php
public function actions(): array
{
    return [
        Action::make('View')->route('reviews.show'),
    ];
}
```

You can also link anywhere with the `to`{href="https://raw.githubusercontent.com/Larasell-dev/admin/refs/heads/main/src/Tables/Actions/Action.php"} method:

```php
public function actions(): array
{
    return [
        // The URL can be a static string or a closure that receives the record
        Action::make('Guidelines')->to('https://shop.example.test/guidelines'),
    ];
}
```

## Destructive actions

Each action you add looks the same. That makes destructive actions like deleting a record look
less dangerous than they are. Use the `destructive` method to give the action a red colour. This is visual.

```php
public function actions(): array
{
    return [
        Action::make('Delete', fn (ProductReview $record) => $record->delete())
            ->destructive(),
    ];
}
```

## Confirmation

For destructive actions like deleting a record, show a confirmation dialog the user
must complete. That reduces the chance of them doing an irreversible action.

An `Action`{href="https://raw.githubusercontent.com/Larasell-dev/admin/refs/heads/main/src/Tables/Actions/Action.php"} accepts a `confirm` method:

```php
public function actions(): array
{
    return [
        Action::make('Delete', fn (ProductReview $record) => $record->delete())
            ->confirm(),
    ];
}
```

### Customising the confirmation dialog

The `confirm` method with no parameters is enough. Customise what the user sees:

```php
public function actions(): array
{
    return [
        Action::make('Delete', fn (ProductReview $record) => $record->delete())
            ->confirm(
                title: 'Delete review',
                message: 'This review will be gone forever.',
                confirmButton: 'Delete review',
                cancelButton: 'Keep review',
            ),
    ];
}
```

All arguments are optional.

### Type to confirm

For some destructive actions, require the user to type some text to confirm their action.

```php
public function actions(): array
{
    return [
        Action::make('Delete', fn (ProductReview $record) => $record->delete())
            ->confirm(confirmationText: 'delete'),
    ];
}
```

When the user tries to delete a product review, they're forced to type "delete" into an input
field. They cannot perform the action if what they've entered does not match the required text.

You can make the required text depend on the record:

```php
public function actions(): array
{
    return [
        Action::make('Delete', fn (ProductReview $record) => $record->delete())
            ->confirm(confirmationText: fn (ProductReview $record) => $record->author),
    ];
}
```

The user has to type the author's name to confirm their action.

## Disabling actions

A user can't perform every action. They don't have enough permissions,
or they want to remove a user but they can't remove themselves.

To disable actions use the `disabled` method:

```php
public function actions(): array
{
    return [
        Action::make('Publish', fn (ProductReview $record) => $record->publish())
            ->disabled(fn (ProductReview $record) => $record->is_published),
    ];
}
```

Calling `disabled` without any parameters disables the action for every row.

## Hiding actions

A disabled action still shows up in the menu. When an action makes no sense for a row,
hide it instead with the `hidden` method:

```php
public function actions(): array
{
    return [
        Action::make('Unpublish', fn (ProductReview $record) => $record->unpublish())
            ->hidden(fn (ProductReview $record) => ! $record->is_published),
    ];
}
```

Calling `hidden` without any parameters hides the action for every row. When every action of a
row is hidden, the row has no actions menu.

Larasell refuses to run a hidden action, even when someone sends the request by hand.

Hiding a link action, one that uses `route` or `to`, only removes it from the menu. The page
it links to still opens for anyone who knows the URL. Protect that route yourself, for example
with a policy or middleware.
