PHP code example of fourstacks / nova-checkboxes

1. Go to this page and download the library: Download fourstacks/nova-checkboxes 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/ */

    

fourstacks / nova-checkboxes example snippets


namespace App\Nova;

use Fourstacks\NovaCheckboxes\Checkboxes;

// ...

class Member extends Resource
{
    // ...

    public function fields(Request $request)
    {
        return [
            // ...

            Checkboxes::make('Hobbies'),

            // ...
        ];
    }
}

namespace App;

// ...

class Member extends Model
{
    protected $casts = [
        'hobbies' => 'array'
    ]
}


Checkboxes::make('Hobbies')
    ->options([
        'sailing' => 'Sailing',
        'rock_climbing' => 'Rock Climbing',
        'archery' => 'Archery'
    ])



Checkboxes::make('Hobbies')
    ->options([
        'sailing' => 'Sailing',
        'rock_climbing' => 'Rock Climbing',
        'archery' => 'Archery'
    ])
    ->saveAsString()



Checkboxes::make('Hobbies')
    ->options([
        'sailing' => 'Sailing',
        'rock_climbing' => 'Rock Climbing',
        'archery' => 'Archery'
    ])
    ->saveUncheckedValues()


Checkboxes::make('Hobbies')
    ->options([
        'sailing' => 'Sailing',
        'rock_climbing' => 'Rock Climbing',
        'archery' => 'Archery'
    ])
    ->displayUncheckedValuesOnIndex()

Checkboxes::make('Hobbies')
    ->options([
        'sailing' => 'Sailing',
        'rock_climbing' => 'Rock Climbing',
        'archery' => 'Archery'
    ])
    ->displayUncheckedValuesOnDetail()

Checkboxes::make('Hobbies')
    ->options([
        'sailing' => 'Sailing',
        'rock_climbing' => 'Rock Climbing',
        'archery' => 'Archery'
    ])
    ->columns(3)