belongsToMany method

void belongsToMany(
  1. String name,
  2. Model model, {
  3. String? pivotTable,
  4. required dynamic parentPivotKey,
  5. required dynamic relatedPivotKey,
  6. dynamic parentLocalKey = 'id',
  7. dynamic relatedLocalKey = 'id',
})

Implementation

void belongsToMany(
  String name,
  Model model, {
  String? pivotTable,
  required parentPivotKey,
  required relatedPivotKey,
  parentLocalKey = 'id',
  relatedLocalKey = 'id',
}) {
  _relations.addEntries([
    MapEntry(
      name,
      BelongsToMany(
        related: model,
        parent: this,
        pivotTable:
            pivotTable ??
            '${Singularize.make(model.runtimeType.toString())}_${Singularize.make(runtimeType.toString())}'
                .toLowerCase(),
        parentPivotKey: parentPivotKey,
        relatedPivotKey: relatedPivotKey,
        parentLocalKey: parentLocalKey,
        relatedLocalKey: relatedLocalKey,
      ),
    ),
  ]);
}