Skip to content

Commit

Permalink
Merge pull request #109 from harena-lab/development
Browse files Browse the repository at this point in the history
fix (case/delete): case properties preventing delete
  • Loading branch information
HeitorMatt authored Feb 11, 2021
2 parents 46dd3fd + b50572e commit af04e56
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 af04e56

Please sign in to comment.