Did you see this? Not sure if it is the same issue you're having.
Nova BelongsToMany - Hide fields from relationship's index, but not resource index
Say I have two models / resources: Business and Environment. A business belongs to many environments, an environment can belong to many businesses.
On Nova, I have each individual resource set up, and one of the fields I have on the environment resource index is the number of businesses linked to that environment, as a "quick glance" to sort by most used environment features, things like that.
Now, when I click on a specific Business, I can see the environments for that business, but I can also see all of the fields I have defined for the environments index. I only really want and need to see the name and the pivot column "notes" for the environment that is attached to a business.
Is there a way to specify that a field should only show up on a resource's index, not on the relationship details?
Business fields:
return [
ID::make()->sortable(),
Text::make('Business Name')->sortable(),
BelongsToMany::make('Environment Details', 'environments', Environment::class)
->fields(function () {
return [
Text::make('Notes')->nullable(),
];
}),
];
Environment Fields:
return [
Stack::make('Name & Description', 'name', [
Line::make('Name')
->asHeading(),
Line::make('Description')
->asSmall(),
])->sortable()
->onlyOnIndex(),
Text::make('Name')
->sortable()
->rules('required', 'max:255')
->creationRules('unique:accommodations,name')
->updateRules('unique:accommodations,name,{{resourceId}}')
->showOnIndex(false),
BelongsToMany::make('Providers With This Environment', 'providers', Provider::class),
Number::make('# Providers', 'providers_count')
->sortable()
->onlyOnIndex(),
...AttributeStatusBadge::make($this->resource),
...Metadata::make($this->resource),
];
Please or to participate in this conversation.