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

Blastup logo

Blastup

Blastup provides social media enhancement services including buying Instagram likes, followers, and views, with features like instant delivery and a variety of packages to suit different needs.

Blastup
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
Harpoon: Next generation time tracking and invoicing logo

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing
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
Laravel Cloud logo

Laravel Cloud

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

Laravel Cloud
PhpStorm logo

PhpStorm

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

PhpStorm