trin4ik/nova-switcher

This package is abandoned and no longer maintained. No replacement package was suggested.

A Laravel Nova switcher field.

Installs: 48 266

Dependents: 0

Suggesters: 0

Security: 0

Stars: 12

Watchers: 1

Forks: 6

Open Issues: 4

Language:Vue

v0.4 2023-11-01 05:33 UTC

This package is auto-updated.

Last update: 2024-09-22 23:45:57 UTC


README

!!! Guys, I archived this project because I'm not using it anymore. If you want it, I can transfer my rights to you !!!

Laravel Nova Switcher Field

Replace default Boolean with switcher.
Work on Index/Detail view with xhr, on Form like checkbox.

Installation

composer require trin4ik/nova-switcher

Usage

use Trin4ik\NovaSwitcher\NovaSwitcher;
...
NovaSwitcher::make('Active');

Labels

use Trin4ik\NovaSwitcher\NovaSwitcher;
...
NovaSwitcher::make('Active')
    ->trueLabel('On')
    ->falseLabel('Off');
...
NovaSwitcher::make('Active')
    ->withLabels(true: 'On', false: 'Off');

Confirmation

use Trin4ik\NovaSwitcher\NovaSwitcher;
...
NovaSwitcher::make('Active')
    ->confirmToTrue('enable?')
    ->confirmToFalse('disable?');
...
NovaSwitcher::make('Active')
    ->confirm(toTrue: 'enable?', toFalse: 'disable?');

of couse, you can only use confirmation dialogue to enable, or disable:

use Trin4ik\NovaSwitcher\NovaSwitcher;
...
NovaSwitcher::make('Active')
    ->confirmToFalse('Turn it off?');

Reverse

Also, you can use reverse value (if switcher checked, value is false and vice versa)

NovaSwitcher::make('Active')
    ->reverse();

Thanks to...