Skip to content

Commit

Permalink
fix (case/delete): case properties preventing delete
Browse files Browse the repository at this point in the history
  • Loading branch information
HeitorMatt committed Feb 11, 2021
1 parent 78c09ce commit b50572e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
11 changes: 10 additions & 1 deletion src/adonisjs/app/Controllers/Http/v1/CaseController.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,18 @@ class CaseController {
const trx = await Database.beginTransaction()
try {
const c = await Case.findBy('id', request.input('caseId'))

console.log('============ =============================')
if (c != null) {
await c.versions().delete()
await Permission
.query()
.where('table', 'cases')
.where('table_id', c.id)
.delete()
await CaseProperty
.query()
.where('case_id', c.id)
.delete()
// await c.users().detach()
// await c.quests().detach()
await c.artifacts().delete()
Expand Down
8 changes: 4 additions & 4 deletions src/adonisjs/app/Models/v1/Case.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ class Case extends Model {
artifacts () {
return this.hasMany('App/Models/CaseArtifact')
}

permissions () {
return this.hasMany('App/Models/v1/Permission')
}
//
// permissions () {
// return this.hasMany('App/Models/v1/Permission')
// }

author () {
return this.belongsTo('App/Models/v1/User')
Expand Down

0 comments on commit b50572e

Please sign in to comment.