@shagital/adonisjs-crud-generator
Version:
Adonisjs Admin Panel Generator is a package that helps you quickly scaffold your typical CRUD admin interfaces. It generates the admin panel code based on the existing (migrated) table in the database
30 lines (22 loc) • 771 B
Plain Text
import { column, BaseModel, SnakeCaseNamingStrategy{{otherImports}}} from '@ioc:Adonis/Lucid/Orm'
{{varImport}}
export default class {{pascalName}} extends BaseModel {
public static namingStrategy = new SnakeCaseNamingStrategy()
public static primaryKey = '{{primaryColumn}}'
public static table = '{{tableName}}'
public static selfAssignPrimaryKey = {{autoIncrement}}
{{columnDefinitions}}
public static boot () {
if (this.booted) {
return
}
super.boot()
this.before('create', async (_modelInstance) => { {{createHook}} })
this.before('update', async (_modelInstance) => { {{updateHook}} })
}
{{methods}}
{{relationships}}
public static allowedRelationships(): Array<string> {
return {{relationshipArray}}
}
}