mirror of
https://github.com/ArthurDanjou/artdanj-api.git
synced 2026-01-22 16:00:26 +01:00
initital commit
This commit is contained in:
19
app/Models/File.ts
Normal file
19
app/Models/File.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { DateTime } from 'luxon'
|
||||
import {BaseModel, column} from '@ioc:Adonis/Lucid/Orm'
|
||||
|
||||
export default class File extends BaseModel {
|
||||
@column({ isPrimary: true })
|
||||
public id: number
|
||||
|
||||
@column()
|
||||
public label: string
|
||||
|
||||
@column()
|
||||
public fileName: string
|
||||
|
||||
@column.dateTime({ autoCreate: true })
|
||||
public createdAt: DateTime
|
||||
|
||||
@column.dateTime({ autoCreate: true, autoUpdate: true })
|
||||
public updatedAt: DateTime
|
||||
}
|
||||
19
app/Models/Post.ts
Normal file
19
app/Models/Post.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { DateTime } from 'luxon'
|
||||
import {BaseModel, column} from '@ioc:Adonis/Lucid/Orm'
|
||||
|
||||
export default class Post extends BaseModel {
|
||||
@column({ isPrimary: true })
|
||||
public id: number
|
||||
|
||||
@column()
|
||||
public slug: string
|
||||
|
||||
@column()
|
||||
public likes: number
|
||||
|
||||
@column.dateTime({ autoCreate: true })
|
||||
public createdAt: DateTime
|
||||
|
||||
@column.dateTime({ autoCreate: true, autoUpdate: true })
|
||||
public updatedAt: DateTime
|
||||
}
|
||||
19
app/Models/Subscriber.ts
Normal file
19
app/Models/Subscriber.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { DateTime } from 'luxon'
|
||||
import { BaseModel, column } from '@ioc:Adonis/Lucid/Orm'
|
||||
|
||||
export default class Subscriber extends BaseModel {
|
||||
@column({ isPrimary: true })
|
||||
public id: number
|
||||
|
||||
@column()
|
||||
public name: string
|
||||
|
||||
@column()
|
||||
public email: string
|
||||
|
||||
@column.dateTime({ autoCreate: true })
|
||||
public createdAt: DateTime
|
||||
|
||||
@column.dateTime({ autoCreate: true, autoUpdate: true })
|
||||
public updatedAt: DateTime
|
||||
}
|
||||
40
app/Models/User.ts
Normal file
40
app/Models/User.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { DateTime } from 'luxon'
|
||||
import Hash from '@ioc:Adonis/Core/Hash'
|
||||
import {
|
||||
column,
|
||||
beforeSave,
|
||||
BaseModel,
|
||||
} from '@ioc:Adonis/Lucid/Orm'
|
||||
|
||||
export default class User extends BaseModel {
|
||||
@column({ isPrimary: true })
|
||||
public id: number
|
||||
|
||||
@column()
|
||||
public email: string
|
||||
|
||||
@column()
|
||||
public password: string
|
||||
|
||||
@column()
|
||||
public confirmationToken: string
|
||||
|
||||
@column()
|
||||
public isConfirmed: boolean
|
||||
|
||||
@column()
|
||||
public rememberMeToken?: string
|
||||
|
||||
@column.dateTime({ autoCreate: true })
|
||||
public createdAt: DateTime
|
||||
|
||||
@column.dateTime({ autoCreate: true, autoUpdate: true })
|
||||
public updatedAt: DateTime
|
||||
|
||||
@beforeSave()
|
||||
public static async hashPassword (user: User) {
|
||||
if (user.$dirty.password) {
|
||||
user.password = await Hash.make(user.password)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user