Get expert guidance in a few days with a Laravel code review

Novafieldcheckboxes

silvanite/novafieldcheckboxes image

Novafieldcheckboxes stats

Downloads
628.9K
Stars
69
Open Issues
23
Forks
31

View on GitHub →

A Laravel Nova field to display a number of multi-select options using checkboxes.

Laravel Nova Checkboxes Field

Package maintenance

Unfortunately I am no longer actively working in the Laravel ecosystem and as such am unable to maintian this package. If anyone would like to take over the maintenance of the package please get in touch (open an issue or contact me on Twitter).

Installation

composer require silvanite/novafieldcheckboxes

Usage

use Silvanite\NovaFieldCheckboxes\Checkboxes;
 
Checkboxes::make('Permissions')->options([
'viewNova' => 'Access Admin UI',
'manageUsers' => 'Manage Users',
]),

Configuration

You can customise how the values from checkbox fields are passed to your scripts. By default it's will cast all numeric keys to floats or integers, e.g. [1, 2, 3] instead of ["1", "2", "3"]. You can save disable this feature by calling withoutTypeCasting() to have the original array keys returned unmodified.

use Silvanite\NovaFieldCheckboxes\Checkboxes;
 
Checkboxes::make('Permissions')->options([
1 => 'Access Admin UI',
2 => 'Manage Users',
])->withoutTypeCasting(),

You can also customise the number of columns in which options will be displayed by calling columns()

use Silvanite\NovaFieldCheckboxes\Checkboxes;
 
Checkboxes::make('Permissions')->options([
1 => 'Access Admin UI',
2 => 'Manage Users',
])->columns(4),

Example using eloquent

Here is an example of how you might use an eloquent model with Checkboxes.

use Silvanite\NovaFieldCheckboxes\Checkboxes;
 
Checkboxes::make('users')
->options(App\User::pluck('name', 'id'))
->withoutTypeCasting(),

Support

If you require any support please contact me on Twitter or open an issue on this repository.

License

MIT

Silvanite photo

Enabling Business through Modern Technology

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.


Silvanite Novafieldcheckboxes Related Articles

Statamic logo

Statamic

The drop-in ready Laravel CMS you’re been waiting for. Go full-stack or headless, flat file or database – it’s up to you.

Statamic
Tighten logo

Tighten

We help companies turn great ideas into amazing apps, products, and services.

Tighten
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
Get expert guidance in a few days with a Laravel code review logo

Get expert guidance in a few days with a Laravel code review

Expert code review! Get clear, practical feedback from two Laravel devs with 10+ years of experience helping teams build better apps.

Get expert guidance in a few days with a Laravel code review
CodeKudu logo

CodeKudu

Stand-ups, Retrospectives, and 360° Feedback for the entire team. 50% off with code LARAVELNEWS.

CodeKudu
LoadForge logo

LoadForge

Scalable load testing for web apps & APIs. Simulate real-world traffic and identify breaking points and performance limits with powerful, scalable load tests designed for Laravel.

LoadForge