Custom fields feature.

This commit is contained in:
Ahmed Bouhuolia
2019-09-13 20:24:09 +02:00
parent cba17739d6
commit ed4d37c8fb
64 changed files with 2307 additions and 121 deletions

View File

@@ -0,0 +1,37 @@
import { snakeCase } from 'lodash';
import bookshelf from './bookshelf';
const ResourceField = bookshelf.Model.extend({
/**
* Table name.
*/
tableName: 'resource_fields',
/**
* Timestamp columns.
*/
hasTimestamps: false,
virtuals: {
/**
* Resource field key.
*/
key() {
return snakeCase(this.attributes.label_name);
},
},
/**
* Resource field may belongs to resource model.
*/
resource() {
return this.belongsTo('Resource', 'resource_id');
},
}, {
/**
* JSON Columns.
*/
jsonColumns: ['options'],
});
export default bookshelf.model('ResourceField', ResourceField);