Merge branch 'alpha.4' of https://github.com/strapi/strapi into plugin/content-manager

This commit is contained in:
Pierre Burgy 2017-04-20 18:45:02 +02:00
commit 41e4031f53

View File

@ -395,13 +395,18 @@ module.exports = function(strapi) {
relationship.attribute = pluralize.singular(details.via);
}
const globalId = _.get(
strapi.models,
`${details.collection.toLowerCase()}.globalId`
);
loadedModel[name] = function() {
if (
_.isArray(_.get(details, 'withPivot')) &&
!_.isEmpty(details.withPivot)
) {
return this.belongsToMany(
global[_.upperFirst(details.collection)],
global[globalId],
tableName,
relationship.attribute + '_' + relationship.column,
details.attribute + '_' + details.column
@ -409,7 +414,7 @@ module.exports = function(strapi) {
}
return this.belongsToMany(
global[_.upperFirst(details.collection)],
global[globalId],
tableName,
relationship.attribute + '_' + relationship.column,
details.attribute + '_' + details.column