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

Help make Filament faster! image

Help make Filament faster!

Read article
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
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
The Certification of Competence for Laravel logo

The Certification of Competence for Laravel

A community-driven, proctored assessment across 4 levels designed to validate real-world Laravel knowledge, from Junior to mastery-level Artisan. Official Vue.js, Official Nuxt, Angular, React, JS certifications also available.

The Certification of Competence for Laravel
Celebian logo

Celebian

Celebian is a social media marketing agency specializing in helping their clients go viral on TikTok. Whether you're looking to reach a bigger audience or gain more Tiktok followers, likes, and views, they've got you covered.

Celebian
Shift logo

Shift

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

Shift
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
Statamic logo

Statamic

The drop-in ready Laravel CMS you’re been waiting for. Go full-stack or headless, flat file or database – it’s up to you.

Statamic