fix issues.

This commit is contained in:
Ahmed Bouhuolia
2020-05-05 04:21:37 +02:00
parent 3b25056cbe
commit bd7eb0eb76
41 changed files with 364 additions and 216 deletions

View File

@@ -12,6 +12,9 @@ export default class Item extends TenantModel {
return 'items';
}
/**
* Model modifiers.
*/
static get modifiers() {
const TABLE_NAME = Item.tableName;
@@ -29,6 +32,7 @@ export default class Item extends TenantModel {
* Relationship mapping.
*/
static get relationMappings() {
const Media = require('@/models/Media');
const Account = require('@/models/Account');
const ItemCategory = require('@/models/ItemCategory');
@@ -71,6 +75,19 @@ export default class Item extends TenantModel {
to: 'accounts.id',
},
},
media: {
relation: Model.ManyToManyRelation,
modelClass: this.relationBindKnex(Media.default),
join: {
from: 'items.id',
through: {
from: 'media_links.model_id',
to: 'media_links.media_id',
},
to: 'media.id',
}
},
};
}
}