PHP code example of kayacekovic / nova-action-button

1. Go to this page and download the library: Download kayacekovic/nova-action-button library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

kayacekovic / nova-action-button example snippets


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
    ];
}

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

->text('Execute')

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

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