1. Go to this page and download the library: Download ziffmedia/nova-select-plus 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/ */
ziffmedia / nova-select-plus example snippets
use ZiffMedia\NovaSelectPlus\SelectPlus;
// setup model like normal:
public function statesLivedIn()
{
return $this->belongsToMany(State::class, 'state_user_lived_in')->withTimestamps();
}
// add Nova Resource Field
SelectPlus::make('States Lived In', 'statesLivedIn', State::class),
// assuming in the User model:
public function statesVisited()
{
return $this->belongsToMany(State::class, 'state_user_visited')
->withPivot('order')
->orderBy('order')
->withTimestamps();
}
// inside the Nova resource:
SelectPlus::make('States Lived In', 'statesLivedIn', State::class)
->reorderable('order'),
// inside the Nova resource (exclude all states that start with C)
SelectPlus::make('States Lived In', 'statesLivedIn', State::class)
->optionsQuery(function (Builder $query) {
$query->where('name', 'NOT LIKE', 'C%');
})