coreproc/nova-toggle-fields

A Laravel Nova action that enables you to toggle fields on the index of your resource.

v1.0.1 2022-12-06 08:00 UTC

This package is auto-updated.

Last update: 2024-12-06 12:28:40 UTC


README

A Laravel Nova package that enables you to toggle fields on the index of your resource through a standalone action.

image

Installation

You can install the package into a Laravel app that uses Nova via composer:

composer require coreproc/nova-toggle-fields

Usage

To use the toggle fields action, you need to first add the HasToggleableFields trait to your resource:

use Coreproc\NovaToggleFields\Traits\HasToggleableFields;

class Contact extends Resource
{
    use HasToggleableFields;
    
    .....
}

Then add the the ToggleFields action class inside the actions method along with the parameters:

use Coreproc\NovaToggleFields\Traits\HasToggleableFields;

class Contact extends Resource
{
    use HasToggleableFields;
    
    .....
    
    /**
     * Get the actions available for the resource.
     *
     * @param \Laravel\Nova\Http\Requests\NovaRequest $request
     * @return array
     */
    public function actions(NovaRequest $request)
    {
        return [
            (new ToggleFields(self::class, $this->indexFields($request))),
        ];
    }
    
    ...
}