This Nova field provides a clean way to combine multiple fields into one output.
Installing with composer:
composer require dillingham/nova-grouped-field
use Dillingham\NovaGroupedField\Grouped;
public function fields(Request $request)
{
return [
Grouped::make('User')->fields([
BelongsTo::make('Account'),
BelongsTo::make('User'),
])
]
}
There are a few chainable options available
If you would like to override the default slash separator
Grouped::make('User')->fields([
BelongsTo::make('Account'),
BelongsTo::make('User'),
])->separator('-')
If you want to output the original labels inline with the values
Grouped::make('User')->fields([
BelongsTo::make('Account'),
BelongsTo::make('User'),
])->showLabels()
If you just want plain text output for relationships
Grouped::make('User')->fields([
BelongsTo::make('Account'),
BelongsTo::make('User'),
])->removeLinks()
separator('-') | showLabels() | removeLinks() |
---|---|---|
Grouped
is a nova field like any other.
You can use authorization like ->canSee()
You can decide when to show like ->hideFromIndex()
Hi 👋, Im Brian Dillingham, creator of this Nova package and others
Hope you find it useful. Feel free to reach out with feedback.
Follow me on twitter: @im_brian_d