creode/laravel-nova-account-approval

A simple package which integrates with the laravel-account-approval package to grant additional actions within Nova.

1.0.0 2024-01-17 14:25 UTC

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

A simple package which integrates with the laravel-account-approval package to grant additional actions within Nova.

Installation

You can install the package via composer:

composer require creode/laravel-nova-account-approval

Usage

This package currently just exposes some actions that can be used in Nova resources to activate and deactivate users.

This functionality is tied directly to the laravel-account-approval package, using it as a dependency of this one.

Setting up the actions

To use the actions, you need to add them to your Nova resource. For example, if you have a User resource, you can add the actions like so:

/**
 * Get the actions available for the resource.
 *
 * @param  \Laravel\Nova\Http\Requests\NovaRequest  $request
 * @return array
 */
public function actions(NovaRequest $request)
{
    return [
        (new \Creode\LaravelNovaAccountApproval\Actions\ApproveAccount)
            ->confirmText('Are you sure you want to approve this account?')
            ->confirmButtonText('Approve')
        ->cancelButtonText("Don't Approve"),
        (new \Creode\LaravelNovaAccountApproval\Actions\DeactivateAccount)
            ->confirmText('Are you sure you want to deactivate this account?')
            ->confirmButtonText('Deactivate')
            ->cancelButtonText("Don't Deactivate"),
    ];
}

Actions are configured to be both inline and in bulk so they can be used to easily approve/deactivate multiple users at once from the main screen.

It may also be useful to display the status of the user in the resource index. This can be done by adding the following to the fields method of the resource:

/**
 * Get the fields displayed by the resource.
 *
 * @param  \Laravel\Nova\Http\Requests\NovaRequest  $request
 * @return array
 */
public function fields(NovaRequest $request)
{
    return [
        // Other fields...

        Boolean::make('Activated')
            ->sortable()
            ->rules('required', 'boolean'),

        // More other fields...
    ];
}

Testing

composer test

Changelog

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

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.