Package

Pdmfc Nova Action Button

A Laravel Nova field to run actions.

Package

pdmfc/nova-action-button

View on GitHub →

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.

Pdmfc Nova Action Button Related Articles

NativePHP v4: Build Native iOS and Android UI in Blade image

NativePHP v4: Build Native iOS and Android UI in Blade

Read article
Early View Data Preparation with Laravel View Creators image

Early View Data Preparation with Laravel View Creators

Read article
Integrate Cloudflare Turnstile into Laravel and Livewire image

Integrate Cloudflare Turnstile into Laravel and Livewire

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
Building a Vue SPA with Laravel Part 5 image

Building a Vue SPA with Laravel Part 5

Read article
Blade Authorization Directives for View Security image

Blade Authorization Directives for View Security

Read article
Pushsilver logo

Pushsilver

Pushsilver is simple invoicing for freelancers and small studios — send polished invoices, automate reminders, and get paid on time without the bloat.

Pushsilver
No Compromises logo

No Compromises

Joel and Aaron, the two seasoned devs from the No Compromises podcast, are now available to hire for your Laravel project. ⬧ Flat rate of $9500/mo. ⬧ No lengthy sales process. ⬧ No contracts. ⬧ 100% money back guarantee.

No Compromises
PhpStorm logo

PhpStorm

The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

PhpStorm
Acquaint Softtech logo

Acquaint Softtech

Acquaint Softtech offers AI-ready Laravel developers who onboard in 48 hours at $3000/Month with no lengthy sales process and a 100 percent money-back guarantee.

Acquaint Softtech
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
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