Laravel Cloud is here! Zero-config managed infrastructure for Laravel apps. Deploy now.

Nova Action Button

pdmfc/nova-action-button image

Nova Action Button stats

Downloads
509.8K
Stars
37
Open Issues
15
Forks
25

View on GitHub →

A Laravel Nova field to run actions.

Nova Action Button

This package allows you to execute an action directly on your resource table view.

Installation

composer require pdmfc/nova-action-button

Usage

use App\Nova\Actions\ChangeRole;
use Pdmfc\NovaFields\ActionButton;
 
//...
 
public function fields()
{
return [
ActionButton::make('Action')
->action(ChangeRole::class, $this->id)
//->action(new ChangeRole(), $this->id) using a new instance
];
}

The action() method requires two params - the action class name or a new instance, and the target resource id.

Disabling button

You can use the native Laravel nova readonly() method to prevent users from clicking the button:

ActionButton::make('Action')
->action(ChangeRole::class, $this->id)
->readonly(function () {
return $this->role->name === 'admin';
})

Change the button text

To edit the button text content, use the text() method.

->text('Execute')

Enable the loading animation on button and change color

To enable the loading animation on button and change color, use showLoadingAnimation() and loadingColor('#fff') method.

->showLoadingAnimation()
->loadingColor('#fff') # default is #000

Add a svg to the button

In order to add a svg to the button, you first need to create a vue component containing a svg and then pass the component name to the svg() method.

->svg('VueComponentName')

Change button color

To change button color, use buttonColor('#21b970') method.

->buttonColor('#21b970') # default is .btn-primary color

Caveats

  • Currently, in order to use this field, you still have to declare the action in your resource actions() method.

How to contribute

  • clone the repo
  • on composer.json of a laravel nova application add the following:
{
//...
 
"require" {
"pdmfc/nova-action-button: "*"
},
 
//...
"repositories": [
{
"type": "path",
"url": "../path_to_your_package_folder"
}
],
}
  • run composer update pdmfc/nova-action-button

You're now ready to start contributing!

Changelog

Please see CHANGELOG for more information on what has changed recently.

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.


Pdmfc Nova Action Button Related Articles

Laravel Starter Kits Now Include Toast Notifications image

Laravel Starter Kits Now Include Toast Notifications

Read article
Filament v5.3.0 Released with Deferred Tab Badges and Column Manager Improvements image

Filament v5.3.0 Released with Deferred Tab Badges and Column Manager Improvements

Read article
Filament v5.2.0 Adds a Callout Component image

Filament v5.2.0 Adds a Callout Component

Read article
Livewire wire:click.prevent for Form Handling image

Livewire wire:click.prevent for Form Handling

Read article
Real-time Form Updates with Laravel Livewire's wire:model.live image

Real-time Form Updates with Laravel Livewire's wire:model.live

Read article
Implementing User Confirmation Dialogs in Laravel Livewire with wire:confirm image

Implementing User Confirmation Dialogs in Laravel Livewire with wire:confirm

Read article
Typesense Search logo

Typesense Search

Typesense is an open source, blazing-fast search engine, optimized for helping you build delightful search experiences for your sites and apps. Natively integrated with Laravel Scout.

Typesense Search
Get expert guidance in a few days with a Laravel code review logo

Get expert guidance in a few days with a Laravel code review

Expert code review! Get clear, practical feedback from two Laravel devs with 10+ years of experience helping teams build better apps.

Get expert guidance in a few days with a Laravel code review
Laravel Cloud logo

Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Laravel Cloud
Curotec logo

Curotec

World class Laravel experts with GenAI dev skills. LATAM-based, embedded engineers that ship fast, communicate clearly, and elevate your product. No bloat, no BS.

Curotec
Honeybadger logo

Honeybadger

Simple developer-focused application monitoring for Laravel. Error tracking, log management, uptime monitoring, status pages, and more!

Honeybadger
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Multi-tenant Laravel SaaS Starter Kit that comes with all features required to run a modern SaaS. Payments, Beautiful Checkout, Admin Panel, User dashboard, Auth, Ready Components, Stats, Blog, Docs and more.

SaaSykit: Laravel SaaS Starter Kit