Added settings API
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { DateTime } from 'luxon'
|
||||
import { BaseModel, beforeSave, column } from '@ioc:Adonis/Lucid/Orm'
|
||||
import { BaseModel, beforeSave, column, hasMany, HasMany } from '@ioc:Adonis/Lucid/Orm'
|
||||
import Setting from 'App/Models/Setting'
|
||||
import Hash from '@ioc:Adonis/Core/Hash'
|
||||
|
||||
export default class Employee extends BaseModel {
|
||||
@@ -45,10 +46,17 @@ export default class Employee extends BaseModel {
|
||||
@column({serializeAs: null})
|
||||
public password: string
|
||||
|
||||
@hasMany(() => Setting)
|
||||
public settings: HasMany<typeof Setting>
|
||||
|
||||
@beforeSave()
|
||||
public static async hashPassword(employee: Employee){
|
||||
if(employee.$dirty.password){
|
||||
employee.password = await Hash.make(employee.password)
|
||||
}
|
||||
}
|
||||
|
||||
public isAdmin(): boolean {
|
||||
return this.role === 'admin'
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user