Skip to main content
zerotal

Documentation


Documentation / @zerotal/admin / index / belongsToMany

Function: belongsToMany()

belongsToMany(resource, relationName): RelationManager

Defined in: admin/src/relations/RelationManager.ts:109

A BelongsToMany relation manager. relationName is the relationship method on the parent model (e.g. "roles") — its attach()/detach()/get() drive the pivot. Renders the attached records with Detach + an Attach picker.

class UserResource extends Resource { static relations() { return [belongsToMany(RoleResource, "roles").pivotColumns([{ key: "assigned_at" }])]; } }

Parameters

resource

typeof Resource

relationName

string

Returns

RelationManager